OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Programming Questions Remove field constraint on API route

This topic contains 4 replies, has 3 voices, and was last updated by  Bhavesh Tailor 7 years, 2 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
  • #25312

    stef
    Participant

    The create user api route has a constraint that disallows the password attribute in the api call.

    I am currently facing the following requirement:

    1. user creates an (unconfirmed) account by setting his email and password
    2. Upon submit, confirmation email is sent and visiting the link in the email activates the account.

    The existing api call has 2 constraints preventing this, username cannot be empty and password is not whitelisted to be passed through the api. How could I override these validations?

    Thanks!


    Dream, in a pragmatic way.
    — Aldous Huxley

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #25313

    Vova Soroka
    Participant

    Hello @stef,

    By default API checks all constraints from “Default” and “api” validation groups. There is no easy way to disable a particular constraint due to restrictions of Symfony forms. You can try to change validation group using “form_options” (please see https://github.com/orocrm/platform/blob/master/src/Oro/Bundle/ApiBundle/Resources/doc/configuration.md#entities-configuration-section), but I cannot recommend this way because in this case you will lose all default constraints and you have to implement and maintain your own constraints.

    For now I do not see a solution for this issue, but I will try to find it. Please let me know if you have any ideas how to disable a particular constraint. I guess it might be useful in some cases like your.

    #25314

    Bhavesh Tailor
    Participant

    Hi ,

    Can you suggest me how to remove b2bcustomer validation constraint from inline-edit datagrid . While i am trying to click on update it’s follow below link

    http://uourdomain.local/app_dev.php/api/rest/latest/entity_data/OroCRM_Bundle_SalesBundle_Entity_Opportunity/90
    and then pass an error : –

    {“code”:400,”message”:”Validation Failed”,”errors”:{“errors”:[“This value should not be blank.”],”children”
    :{“status”:[],”owner”:[]}}}

    This error getting because of null value for b2bcustomer into orocrm_sales_opportunity table and inside validation.yml

    customer:
    – Valid: ~
    – NotBlank: ~

    Please suggest how to disable validation for inline edit datagrid ..

    Thank You in advance

    Bhavesh


    Bhavesh

    #25315

    Bhavesh Tailor
    Participant

    Hello ,

    Is there any way to override OroCRM/Bundle/SalesBundle/Resources/config/validation.yml form our custom bundle . i did try validation_groups into custom folder opportynity_type.php like

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
    $resolver->setDefaults(
    array(
    ‘data_class’ => ‘OroCRM\Bundle\SalesBundle\Entity\Opportunity’,
    ‘intention’ => ‘opportunity’,
    ‘validation_groups’ => [‘ms_edit’]
    )
    );
    }

    it’s not work for opportunity datagrid inline edit . Please suggest me how can i solve this issue .
    As Per mention into above post while i remove customer constraint from validation.yml and clear the cache it’s work for me but with this constraint i am not able to edit datagrid data .

    Thank You


    Bhavesh

    #25316

    Bhavesh Tailor
    Participant

    Hi ,

    Please help me.

    I did remove b2b customer field from opportunity thats why into my table orocrm_sales_opportunity customer_id is null. While i trying to edit status,probability etc. then i got error “This value should not be blank.” . While i remove code from

    OroCRM/Bundle/SalesBundle/Resources/config/validation.yml

    customer:
    – Valid: ~
    – NotBlank: ~

    Then I am able to update fields . How can i override this validation.yml for inline edit datagrid

    Is there any way to override OroCRM/Bundle/SalesBundle/Resources/config/validation.yml form our custom bundle . i did try validation_groups into custom folder

    /Workspace/orocrmdemo/src/MarketSnap/Bundle/SalesBundle/Form/Type/OpportunityType.php

    or also try

    Workspace/orocrmdemo/src/MarketSnap/Bundle/SalesBundle/Form/Extension/OpportunityTypeExtension.php

    like

    it’s not work for opportunity datagrid inline edit . Please suggest me how can i solve this issue .
    As Per mention into above post while i remove customer constraint from validation.yml and clear the cache it’s work for me but with this constraint i am not able to edit datagrid data .

    Thank You


    Bhavesh

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

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

Back to top