Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot get value from doctrine_orm_time filter with mapped set to false #3236

Closed
webdevilopers opened this issue Sep 9, 2015 · 3 comments
Closed

Comments

@webdevilopers
Copy link
Contributor

I have a doctrine_orm_time filter night_shift_start that is not mapped to my TimekeepingEntry admin:

$datagridMapper
            ->add('night_shift_start', 'doctrine_orm_time', array(
                'show_filter' => true,
                'field_options' => array(
                    'hours' => array(20, 22),
                    'with_minutes' => false,
                    'mapped' => false
                )
            ))

After setting the filter to a value and submitting I'm getting the following dump on the filter data in my custom CRUDController:

$datagrid = $this->admin->getDatagrid();
$datagridFilters = $datagrid->getFilters();
dump($datagridFilters);

bildschirmfoto vom 2015-09-09 13 45 28

As you can see the value index is not set and since then not available with:

echo $datagridFilters['night_shift_start']->getValue()['value'];

This seems to be caused by the mapped option. Setting the option to true and dumping without(!) submitting will show the expected format:
bildschirmfoto vom 2015-09-09 13 49 11

Submitting the filter is not possible:
TimekeepingEntry has no field or association named night_shift_start

Any idea how to solve this?

BTW: why does the mapped option have to be set on the field_options and not the general third parameter array?

@webdevilopers
Copy link
Contributor Author

I tried the following solution as workaround:

$nightShiftStart = $datagrid->getForm()->get('night_shift_start')->getData();

Seen on: http://stackoverflow.com/questions/20440836/sonata-admin-how-to-read-not-mapped-field

But the value will again be empty.

The only quick workaround I found:

$nightShiftStart = $request->get('filter')['night_shift_start']['value']['hour'];

@core23
Copy link
Member

core23 commented Mar 15, 2019

This issue is very old. Can you please check this against the latest stable / master version?

Feel free to reopen, if the error still exists.

A PR would be welcome if you reopen this issue.

@core23 core23 closed this as completed Mar 15, 2019
@webdevilopers
Copy link
Contributor Author

Sorry, but I'm no longer working on this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants