You are here

function farm_asset_form_validate in farmOS 7

Asset validate handler.

Parameters

array $form: The form array.

array $form_state: The form state array.

1 string reference to 'farm_asset_form_validate'
farm_asset_form in modules/farm/farm_asset/farm_asset.pages.inc
Asset form.

File

modules/farm/farm_asset/farm_asset.pages.inc, line 178
Farm asset pages.

Code

function farm_asset_form_validate(array $form, array &$form_state) {
  $farm_asset = (object) $form_state['values']['farm_asset'];
  field_attach_form_validate('farm_asset', $farm_asset, $form, $form_state);

  // If the 'archived_boolean' checkbox has changed, update the asset.
  if ($form_state['values']['archived_boolean'] != $form['asset_status']['archived_boolean']['#default_value']) {

    // If it is checked, set the asset's archived date to current timestamp.
    if (!empty($form_state['values']['archived_boolean'])) {
      $form_state['values']['archived'] = REQUEST_TIME;
    }
    else {
      $form_state['values']['archived'] = 0;
    }
  }
}