/**
* Begin of custom development
*/
$value = new stdClass();
$value->id = 7;
$value->value = $_POST['article_classes'];
$currentValues = json_decode($article->get('extra_fields'));
//If no previous Value
if(empty($currentValues) || !is_array($currentValues)) {
$currentValues = array();
$currentValues[] = $value;
} else {
foreach ($currentValues as $key => $oneValue) {
if($oneValue->id == 7) {
$currentValues[$key] = $value;
}
}
}
$article->set('extra_fields', json_encode($currentValues));
/**
* End of custom development
*/
Please Log in to join the conversation.
$vars['var2']->set('extra_fields', json_encode($currentValues));
Please Log in to join the conversation.
$value = new stdClass();
$value->id = 7;
$value->value = $_POST['article_classes'];
$currentValues = json_decode($vars['var1']-->get('extra_fields'));
//If no previous Value
if(empty($currentValues) || !is_array($currentValues)) {
$currentValues = array();
$currentValues[] = $value;
} else {
foreach ($currentValues as $key => $oneValue) {
if($oneValue->id == 7) {
$currentValues[$key] = $value;
}
}
}
$vars['var2']->set('extra_fields', json_encode($currentValues));
Please Log in to join the conversation.
You should be able to set an error using the following, but I don't see any error handling in your code.- a validation issue when selecting a value in the field
$vars['var1']->setError( 'ERROR_MESSAGE_HERE' );
Your code has 2 dashes in the get usage, but should only have 1.- a fatal error with Call to undefined function get() when trying to save the blog
Please Log in to join the conversation.
Please Log in to join the conversation.
Please Log in to join the conversation.