Covering OroCRM topics, including community updates and company announcements.  Subscribe

Forums OroCRM OroCRM – Programming Questions two type for one filed

This topic contains 1 reply, has 2 voices, and was last updated by Yevhen Shyshkin Yevhen Shyshkin 1 year, 11 months ago.

  • Creator
  • #54076

    Hi EveryBody,
    I have to type for one filed of entity and I want to show each of them in special condition
    but I don’t want to define form type of entity 2 time
    Is there any solution?
    for example class1 have ‘name; field

    in class1Type I add below code
    $builder->add(‘name’, ‘type1_name’)
    ->add(‘name’, ‘type2_name’) ;

    and in twig when a checkbox is checked I will show name as type1_name otherwise show name as type2_name

Viewing 1 replies (of 1 total)
  • Author
  • #54077
    Yevhen Shyshkin
    Yevhen Shyshkin


    You can handle this logic using form events and JS. First you have to render these two fields at frontend and show/hide them depends on the checkbox state, and then you have to add appropriate form field to your form based on submitted checkbox state using form events (probably, PRE_SUBMIT).

    Alternative solution – you might have both fields with different names (e.g. nameType1 and nameType2), make sure they aren’t mapped to entity (option mapped=false), handle their visibility in JS and after form is submitted set one of the values to entity manually or using form events.

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.

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

Yes No