Reference:
The below is taken from here
Arrays should be formatted with a space separating each element (after the comma), and spaces around the => key association operator, if applicable:
$some_array = array('hello', 'world', 'foo' => 'bar');
Note that if the line declaring an array spans longer than 80 characters (often the case with form and menu declarations), each element should be broken into its own line, and indented one level:$form['title'] = array( '#type' => 'textfield', '#title' => t('Title'), '#size' => 60, '#maxlength' => 128, '#description' => t('The title of your node.'), );Note the comma at the end of the last array element; This is not a typo! It helps prevent parsing errors if another element is placed at the end of the list later.
Issue
The above doesn't mention how to handle the situation where there is a line wrapping at say #description.
For example.
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#size' => 60,
'#maxlength' => 128,
'#description' => t('The title of your node is lets say \
greater than 80 characters.'),
);
For the above code snippet, we get an error on array indentation saying...
expected 2 spaces but found 4 ....
Temporary workaround
Code as below.
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#size' => 60,
'#maxlength' => 128,
'#description' => t('The title of your node is lets say \
greater than 80 characters.'),
);
Please let me know if this is an intended behaviour ( no pun intended ).
If it is so, i just wanted to express my opinion that the temporary workaround solution makes visual separation between keys and values a little difficult.
Comments
Comment #1
klausiComment #2
klausiI could not reproduce the error, both of your examples work fine with the latest version of drupalcs. Could you try again?
Comment #3
klausiReopen if this is still an issue.