OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM How do I define filter for 'Contact' field in my form?

This topic contains 3 replies, has 2 voices, and was last updated by  Yurii Muratov 6 years, 1 month ago.

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

  • Creator
    Topic
  • #30847

    spyout98
    Participant

    I have a custom CRUD that is related with Contact. Because of that, I have a ‘Contact’ form field on my form. But, It appears all Contacts without any filtering. How do I define a filter to only show Contacts that match with my filter? Ex: Contact there is a field called ‘first_name’, and I want to show in this field only Contacts that first name starts with ‘A’ or something like this.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #30848

    Yurii Muratov
    Participant

    Hello, @spyout98.

    I think, the oro_contact_select form type (https://github.com/oroinc/crm/blob/master/src/Oro/Bundle/ContactBundle/Form/Type/ContactSelectType.php) may help you. Please try to change the form type to oro_contact_select for your relation.

    Could you please tell me how did you create your entity with relation to contact entity – do you create entity class and migrations, or did you create custom entity only with migration, or did you create your entity in UI? After that, i will be able to explain how to change tis form type.

    #30849

    spyout98
    Participant

    A typical inserting of Contact form field in my “FormType” is something like that:

    # my/path/to/Form/Type/FormType.php
    (…)
    $builder->add(
    ‘contact’,
    ‘oro_contact_select’,
    [
    ‘required’ => false,
    ‘label’ => ‘oro.sales.opportunity.contact.label’
    ]
    )

    (…)

    How do I pass a parameter that make a filter (like ‘firstName = “John”‘) or defines that datagrid ‘XYZ’ that will be showed when user clicks in hamburger icon on right side of field?

    #30850

    Yurii Muratov
    Participant

    @spyout98, if you just want to limit the list of contacts at the choises list, in this case the easest way will be to use common symfony’s entity form type https://symfony.com/doc/current/reference/forms/types/entity.html#using-a-custom-query-for-the-entities and declare custom query to limit the list of contacts

Viewing 3 replies - 1 through 3 (of 3 total)

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

Back to top