You are here

function rooms_unit_edit_form_validate in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

Form API validate callback for the booking unit form.

1 string reference to 'rooms_unit_edit_form_validate'
rooms_unit_edit_form in modules/rooms_unit/rooms_unit.admin.inc
Form callback: create or edit a unit.

File

modules/rooms_unit/rooms_unit.admin.inc, line 462
Rooms editing UI.

Code

function rooms_unit_edit_form_validate(&$form, &$form_state) {

  // Notify field widgets to validate their data.
  entity_form_field_validate('rooms_unit', $form, $form_state);

  // Validate price field.
  if (!empty($form_state['values']['base_price']) && !is_numeric($form_state['values']['base_price'])) {
    form_set_error('Base price error', t('%name: you must enter a numeric value for the price.', array(
      '%name' => t('Base price'),
    )));
  }
  if (!empty($form_state['values']['multiple']) && (!is_numeric($form_state['values']['multiple']) || $form_state['values']['multiple'] < 1)) {
    form_set_error('Multiple units error', t('%name: you must enter at least 1 as the number of multiple units.', array(
      '%name' => t('Multiple units'),
    )));
  }
}