Here is a small PHP code which I am not clear with.

/**
* Form for configurable Drupal action to beep multiple times
*/
function beep_multiple_beep_action_form($context) {
$form['beeps'] = array(
'#type' => 'textfield',
'#title' => t('Number of beeps'),
'#description' => t('Enter the number of times to beep when this action executes'),
'#default_value' => isset($context['beeps']) ? $context['beeps'] : '1',
'#required' => TRUE,
);
return $form;
}

In the above user defined function return $form what does it return? How do you access the individual elements of $form what is the significance of writing beeps in square braces in $form

function beep_multiple_beep_action_validate($form, $form_state) {
        $beeps = $form_state['values']['beeps'];
        if (!is_int($beeps)) {
        form_set_error('beeps', t('Please enter a whole number between 0 and 10.'));
        }
        else if ((int) $beeps > 10 ) {
        form_set_error('beeps', t('That would be too annoying. Please choose fewer than 10
        beeps.'));
        } else if ((int) $beeps < 0) {
        form_set_error('beeps', t('That would likely create a black hole! Beeps must be a
        positive integer.'));
        }
}

In above code what is

$beeps = $form_state['values']['beeps'];

line doing?

beep_multiple_beep_action_form() is a function to build an array, you can use print_r to display the array:

$a = beep_multiple_beep_action_form($context);
print_r($a);

But you need to search where this function is used, in order to see the original array.
This code $beeps = $form_state['values']['beeps']; instead is used to display part of a multidimensional array, something like this:

array(
    'values' => array('beeps' => 'some data')
);

bye.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.