Forums

Covering OroCommerce, OroCRM, OroPlatform topics, including community updates and company announcements.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

Forum Replies Created

Viewing 10 replies - 1 through 10 (of 10 total)
  • Author
    Replies
  • in reply to: Validation constraints not being applied #34246

    adamlundrigan
    Participant

    Argh! I knew it would be something simple I was missing. Thanks!

    in reply to: Validation constraints not being applied #34244

    adamlundrigan
    Participant

    Copy-and-paste error, probably. Thanks for catching that for me ;)

    in reply to: Validation constraints not being applied #34242

    adamlundrigan
    Participant

    The validations are being loaded, the fields are labelled with the red star, and the span element for datetime inputs does have the validation rules enumerated there:

    I think it’s a case of the validation not being applied inside the collection. I added a text field and gave it a NotEmpty validator. When I remove the empty row from the collection and try to submit I see this:

    but if I add an empty row to the Schedule collection and submit again I don’t get validation errors on the fields:

    in reply to: Validation constraints not being applied #34240

    adamlundrigan
    Participant

    I’ve tried this as well:

    Same result. Inspecting the Javascript, the start and end field of each element of the collection have this in the “data-validation” attribute:

    I have another entity with custom validation (validation rules defined in same file, but form is rendered on a different page) and this is what I see when I inspect that field:

    No idea if that’s even relevant.

    in reply to: Returning relationship entities in JSON.API response #34217

    adamlundrigan
    Participant

    Thanks to @vsoroka on GitHub for pointing out a better way to do this (link). I didn’t think to look at the JSON.API docs, which in hindsight seems a pretty obvious course of action :/

    JSON.API has an “include” query string parameter which specifies the related entities that should be included in the response.

    in reply to: Returning relationship entities in JSON.API response #34216

    adamlundrigan
    Participant

    Not sure if it’s the best or most efficient way but it can be accomplished by enumerating the fields for each associated entity inline, like so:

    (Note: these examples don’t use the same custom entity as I used in my original question)

    The JSON.API response will now have an “included” key with serialized copies of each related entity. Example:

    in reply to: Workflow transition form with custom page template #34185

    adamlundrigan
    Participant

    Marking as resolved

    in reply to: Workflow transition form with custom page template #34184

    adamlundrigan
    Participant

    You can create form listener, but i’m not sure that you will get access to $workflowItem

    Thanks, I’ll give that a try.

    One question, $transitionForm is creating from $workflowItem->getData(), i don’t understand, why do you select each signoff from form and again set it to $workflowItem data?

    In my workflow I have a custom action “complete_course_offering” to process the admin’s selection for each Registration (stored in the oro_entity_changeset):

    That custom action just iterates over the collection of Registration records for the Course and transits each record’s workflow based on what the admin selected (Complete or Incomplete).

    When that custom action attempts to pull the data from the “signoff” element of the WorkflowItem, like this:

    It gets a NULL. The purpose of the processSignoffDataOnFormSubmit I showed in my previous post is to take the data submitted through the oro_entity_changeset element and stash it in the workflow item.

    I’ve also tried passing the signoff form data through a parameter on the action definition, eg:

    (where “signoff” is the name of the form element added under form_options -> attribute_fields section, and also a workflow attribute.)

    in reply to: Workflow transition form with custom page template #34182

    adamlundrigan
    Participant

    Wow, thanks! I’ve read through what you created there and it’s nearly identical to what I had…glad I was on the right track at least :)

    • I use {{app.request.attributes.get(‘workflowItemId’)}} to retrieve the ID of the workflow whereas you overrode WorkflowController::transitionAction to inject it. I don’t like pulling request data directly into the template, so I’ll use your approach instead ;)
    • You use the new inline editing (which interacts with the API to do async updates, right?) whereas I used the old editable grid cells method along with an oro_entity_changeset form element, which sends the entity modifications along with the transition form submission.
    • I was missing the “redirect” action in my workflow transition definition

    One additional requirement that I didn’t outline in my original post was that the changes made in the datagrid to the Registration entity shouldn’t be applied until the Course entity is actually transitioned. Otherwise, one could start the transition, change the record statuses, then not submit the transition form and the Registration entities will have been updated but the Course will not have been transitioned. So I’ll stick with using the oro_entity_changeset method for now as it gives me protection against that. (I could have the datagrid update a “shadow” field on the Registration (transitionalStatus, or similar) and then as part of the Course transition copy the values from there into the “status” field…then, if the course isn’t transitioned the “real” status field doesn’t get updated.

    After picking up a few tips from your example and a bit more poking around myself I’ve sorted out everything that I was missing to get my approach to work. The major missing piece was needing to override Oro\Bundle\WorkflowBundle\Controller\WidgetController::transitionFormAction to process the data provided by oro_entity_changeset and store it in WorkflowItem#data:

    Is there a cleaner way to inject this logic into the transition form processing than overriding the whole controller action?

    Thanks for your help!

    in reply to: Workflow transition form with custom page template #34177

    adamlundrigan
    Participant

    Could you please tell me what do you mean under arbitrary widget?

    The transitionForm.html.twig page has one widget / section / datablock (not sure what the correct terminology is) called “General Information”. I was looking to add a second one to the page without having to copy the whole exisitng template to my own bundle just to add the necessary entry into the dataBlocks variable.

    I want to understand what do you using editable grid cells with workflow transition form? If you want to update all yours Registration entities after choosing “attended” or “absent” just write your own transition_definitions. Here is example how you can do it.

    When an admin triggers the “complete” transition on the course they must make a separate Complete/Incomplete selection per each one of those Registration records (basically a “did they attend?” question for each attendee).

    I’ve set this up by overriding the transition form template to add the datagrid which populates selections into a hidden form elememt on the transition form. It’s probably not ideal but that seems to work fine (the admin’s selections in the datagrid are sent when the transition form is submitted). The part that’s tripping me up currently is that the transition handler does nothing when you specify a custom page template. Do I need to override the transition handler too?

    P.S. editable grid cells is deprecated feature, better use inline editing.

    Thanks for the tip!

Viewing 10 replies - 1 through 10 (of 10 total)
Back to top

You will be redirected to [title]. Would you like to continue?

Yes No

You will be redirected to [title]. Would you like to continue?

Yes No