OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions oro_entity_create_or_select_inline

This topic contains 13 replies, has 4 voices, and was last updated by  prganvani 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
  • #33660

    alendo
    Participant

    Hi
    I followed the steps to create a oro_entity_create_or_select_inline field, but I have two problems: the autocomplete does not work for me, and even if the datagrid works, when I select a row in the datagrid nothing happens in the input field.
    I added also form_type and grid_name to my entity config.
    Do you have any suggestion?
    thanks
    Ale
    search.yml

    service.yml

    class ProfessionSelectType extends AbstractType
    {
    /**
    * {@inheritdoc}
    */
    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
    $resolver->setDefaults(
    [
    ‘autocomplete_alias’ => ‘professions’,
    ‘configs’ => [
    ‘placeholder’ => ‘ec.event_professions.form.choose_profession’
    ],
    ]
    );
    }

    /**
    * {@inheritdoc}
    */
    public function getParent()
    {
    return ‘oro_entity_create_or_select_inline’;
    }

    /**
    * {@inheritdoc}
    */
    public function getName()
    {
    return ‘educa_profession_select’;
    }
    }

Viewing 13 replies - 1 through 13 (of 13 total)
  • Author
    Replies
  • #33661

    Alexandr Smaga
    Participant

    Hey @alendo!

    Are there any JS/PHP error when trying to search(just open autocomplete box) ?
    Also did you run reindex on your existing entities when configure search for them ?

    #33662

    alendo
    Participant

    Hi @Alexndr
    No, there is not any js/php error.
    I reindexed and in log file I see reindex log for professions as:

    so I think that it is correctly indexed.
    My concern is that autocomplete doesn’t work but also select from grid: are these two things related?
    Thank you
    Alessandra

    #33663

    alendo
    Participant

    I tried also to search my entity by using the search form on the top and it works with autocomplete!

    #33664

    Yevhen Shyshkin
    Participant

    Hello, alendo.

    As for search autocomplete:

    1) A bit confusing thing that you have only description in search index, but use name to render results – maybe, you should add name to search index too?
    2) You can check real response coming from backend using firebug (on similar tool), just check JSON response.
    3) You can add a breakpoint into SearchHandler::search and check whether is really can find requested entities.

    As for selecttion from grid:

    1) Look’s like you didn’t specify grid name you want to use. You can do that either in entity configuration, or manually as a form type option.
    2) Grid you are using to select entities must have identifier column (“id” by default) that is used to set data to selector.

    #33665

    alendo
    Participant

    Thanks for your answer.
    For search autocomplete:
    1 – I added name to search index, I suppose

    2 – The returned json says this:
    {“results”:[],”hasMore”:false,”errors”:[“Access denied.”]}
    I suppose there is an ACL problem but I don’t understand where, because I’m working with admin user.

    For selection from grid (this is a big concern!) it seems all ok:
    1 – I added form_type and grid_name to my entity config as I said in the first post.

    2 – The grid works, but when I select a row from the grid the input field doesn’t change, remains empty.

    #33666

    Yevhen Shyshkin
    Participant

    > 1 – I added name to search index, I suppose
    If your entity has property name then you have to set “name: name” in search yml, if no – replace name with description in search handler definition (here – [“name”]).

    > ”errors”:[“Access denied.”]
    This is where you have to dig into the problem. Look’s like you don’s have an acces to ACL resource “educacloud_professions_view”. You can check it using method SecurityFacade::isGranted.

    > when I select a row from the grid the input field doesn’t change, remains empty.
    I think it’s a consequence of ACL issue. Fix it and try this case again.

    #33667

    alendo
    Participant

    Hello Yevhen
    it returns access denied on the autocomplete query. If I try the query using the browser url input it doesn’t work:

    returns a stack trace error:

    If I try another autocomplete query it works, for example:

    and returns:

    #33668

    Yevhen Shyshkin
    Participant

    Please, check whether you have as access to ACL resource “educacloud_professions_view”. You can add breakpoint here and check it.

    #33669

    alendo
    Participant

    Hello Yevhen
    I stepped forward and now almost works even if I cannot see the value of the field (autocomplete give results but they are blank options, and when I select one option the field seems full but there is not a value inside, when I save it saves the right value). I changed the name of the ACL in the controller: I put the same name in the route name and in the ACL id. I don’t understand exactly the reason, because in my mind the first is the route name and the ACL id is another thing.

    #33670

    Yevhen Shyshkin
    Participant

    > autocomplete give results but they are blank options, and when I select one option the field
    Please, check whether your entity has properties that you defined in search handles definition (in your code there is only one “name”).

    > the first is the route name and the ACL id is another thing.
    That’s correct, these are two diferenct things – you don’t have to have the same name for them.

    #33671

    alendo
    Participant

    It works!
    Thanks

    #33672

    prganvani
    Participant

    I use same come but got an error

    Fatal error: Uncaught exception ‘Symfony\Component\DependencyInjection\Exception\RuntimeException’ with message ‘The parent definition “plugins_helper.autocomplete.name.search_handler” defined for definition “plugins_helper.form.autocomplete.industry.search_handler” does not exist.’

    #33673

    prganvani
    Participant

    error is: The option “grid_name” must be set.

    I already set grid_name and from_type in entity.

    “form”={
    * “form_type”=”helper_industry_select”,
    * “grid_name”=”helper-industry-grid”,
    * },

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

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

Back to top