I have a custom form, that iI develop on a custom module to get some fields from a content type with an entity reference.

All is good, I can get all information, and I can save the chosen value on a field of content type.

My problem is: why is it that the first input radio doesn't save and show me the max, but I have 0 on the field like a value.

My code to create the field of form:

'#type' => 'radios',
'#title' => $critere->title,
'#options' => $option_bareme,
'#default_value' => isset($machine_notation->field_note_machine['und'][0]['value']),
'#attributes' => array(
  'class' => array(
  // 'id' => array(
  //  $machine_nota_id['target_id']
  // ),
  'name' => array(
'#ajax' => array(
  'callback' => 'test_ajax_form_action',
  'wrapper' => $machine_nota_id['target_id'],
  'method' => 'replace',
  'effect' => 'fade',
  //'event' => 'change',
  'parameter' => array('idmachine'=> $machine_nota_id['target_id'])

And my code for saving with ajax without submitting, only by choosing the value:

$machnot = node_load($form_state['triggering_element']['#ajax']['parameter']['idmachine']);
$machnota = entity_metadata_wrapper('node', $machnot);
// $machnota->field_note_machine->set($form_state['triggering_element']['#value']);
$machnota->field_note_machine = $form_state['triggering_element']['#value'];

and finally my render and my problem:

enter image description here

I have checked the name of the input, also the ID and the value is not the same! It gives from 50 only 12 values, and the first input doesn't save and doesn't get the value back from the node.

Sorry for my bad english and thanks to all :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.