OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums 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 7 years, 9 months ago.

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

  • Creator
    Topic
  • #25227

    golriz.nourani
    Participant

    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?
    Thanks
    ——————-
    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
    Replies
  • #25228

    Yevhen Shyshkin
    Participant

    Hello.

    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)

The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.

Back to top