How to set value if form didn't go through validation?

function mymodyle_myform_form($form_state) {
  $form['name_field'] = array(
    '#type'       => 'textfield',
    '#size'       =>  '5',
  );
  return $form;
}
function mymodyle_myform_form_validate($form, &$form_state) {
  //any condition
  if ($form_state['value']['name_field'] == '123') {
    form_set_value('name_field', 'Error in name field', $form_state);
    form_set_error('name_field'); 
  }
}

Is there any way to return value to form after bad validation?

Comments

justageek’s picture

What are you trying to do exactly? When the form validation fails, what value are you trying to return and when you say "return" the value, what do you mean?