function rooms_periodic_pricing_form_rooms_unit_edit_form_alter in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7
Implements hook_form_FORM_ID_alter().
File
- modules/
rooms_pricing/ modules/ rooms_periodic_pricing/ rooms_periodic_pricing.module, line 6
Code
function rooms_periodic_pricing_form_rooms_unit_edit_form_alter(&$form, &$form_state) {
$unit = $form['#entity'];
$form['weekly_monthly_discount'] = array(
'#type' => 'fieldset',
'#title' => t('Weekly/Monthly discount'),
'#tree' => FALSE,
'#weight' => -97,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['weekly_monthly_discount']['weekly_discount'] = array(
'#type' => 'textfield',
'#title' => t('Weekly discount'),
'#default_value' => isset($unit->weekly_discount) ? $unit->weekly_discount : '',
'#size' => '5',
'#field_suffix' => t('% (> 7 days)'),
'#description' => t('You can provide here a percentage that will be applied as a discount to the standard cost for bookings that exceed 7 days.'),
'#maxlength' => 10,
);
$form['weekly_monthly_discount']['monthly_discount'] = array(
'#type' => 'textfield',
'#title' => t('Monthly discount'),
'#default_value' => isset($unit->monthly_discount) ? $unit->monthly_discount : '',
'#size' => '5',
'#field_suffix' => t('% (> 28 days)'),
'#description' => t('You can provide here a percentage that will be applied as a discount to the standard cost for bookings that exceed 28 days.'),
'#maxlength' => 10,
);
if (isset($unit->weekly_discount) && $unit->weekly_discount == '0.00') {
$form['weekly_monthly_discount']['weekly_discount']['#default_value'] = '';
}
if (isset($unit->monthly_discount) && $unit->monthly_discount == '0.00') {
$form['weekly_monthly_discount']['monthly_discount']['#default_value'] = '';
}
$form['#validate'][] = 'rooms_periodic_pricing_form_rooms_unit_edit_form_validate';
$form['#attached']['css'][] = drupal_get_path('module', 'rooms_periodic_pricing') . '/css/rooms_periodic_pricing.css';
}