Ok let me try as far as I understand you question.
What is the following syntax?
It is a function definition.
What do all the pieces mean?
This is the ternary operator. It means: If $data
is not an array (!is_array($data))
, return $data
(? $data
) otherwise return an empty string (: ''
)
It is a shorthand for if-else
.
How is it used in the function at the end?
Not sure what you mean here. A function _parse_form_attributes($data, $defaults)
is called witch seems to return a string.
If it in your question refers to $defaults
, then it is just an array that gets build and that contains the following values:
Array (
'type' => 'text',
'name' => $data, // or empty string if $data is an array,
'value' => $value
);
It is used to build an input element, that will look like this:
<input type="text"
name="(value of $data or empty)"
value="(value of $value)"
(value of $extra)
/>