Can i use a static array instead of join ?
Can i use a static array instead of join ?
ziv@kpmbro.com
Posts: 73Questions: 28Answers: 4
in General
Hi
I want to save on queries and instead of "join" the same table over and over , i want to use a static array.
for example : (lets say i got all the "sites" table in a php array )
https://editor.datatables.net/examples/inline-editing/join.html
how can i tell the client side to show the editField from the array?
Thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
found it
I am getting the right values in the dropdown when pressing to edit.
But after I press update i get the this error:
this is my code for the static join:
```php
<?php > ``` ?><?php
Field::inst("offers_main_table.is_offer_pushed_to_another_platform")->options( function () {
return array(
array( 'value' => 0, 'label' => "FALSE" ),
array( 'value' => 1, 'label' => "TRUE" )
);
} )->validator( 'Validate::dbValues');
what did i miss?
Thanks
Hi,
The issue is that you are using the
dbValues
validator to validate that the value submitted is in the database list of options, but as you note above there is no database list of options! Hence the error :-).You should use the
values
built in validation method to check if the submitted value is in a set of values (i.e. an array you defined).Regards,
Allan
Thanks thats was the problem.
Allan does the custom validator method will effect the the values i want to show in the editField?
right now i am not getting any.
How should i point with the editField, because its not really a field in a table its an element in array. (can i point at the key of the element some how)?
Thanks