Melbourne Meetup August 2009 @Em Space
This meetup will happen on Tuesday 11th August from 6:00pm, at the Em Space offices at 289 Flinders Lane.
Pizza and beer/softdrink. Plates and napkins! And more chairs hopefully will be here on time, I'd like to handle 30 people easily, last week we had 20. Catering paid by Em Space - it worked out pretty well last week with an optional $5 donation, we'll do that again. Was the ratio of food to people good?
This is going to be about Forms. I'll be presenting on Drupal 6 form coding, how to do a multistep form, how to add validate/submit handlers. We'll look at Drupal 7 form changes. Also there is a GUI form builder, I think by Nate/quicksketch.
Look forward to seeing you all there.


Ical feed
Remember if you get there
Remember if you get there after 6:30 you need to get someone on the phone - mine is 0425869746. Office is 96395436.
Simon
I wish we had something like
I wish we had something like this in Perth! Probably not enough drupal'ers over here though. All the best with the melbourne meet up!
You should put a call out
You should put a call out like Maedi did in Tasmania last month :) I think it was a surprise response
User icon is a reference to
User icon is a reference to Coraline??
Code as requested
The code we done played with.
<?php
/<strong>
* Implemation of hook_menu
*/
function luv_menu() {
$items = array();
$items['luv/demo'] = array(
'title' => 'LUV test page',
'description' => 'Show some info on this page.',
'page callback' => 'foobar_demo_page',
'access callback' => 'user_access',
'access arguments' => array('access content'),
);
$items['luv/form'] = array(
'title' => 'LUV test form',
'description' => 'Calculate some stuff.',
'page callback' => 'drupal_get_form',
'page arguments' => array('foobar_demo_form'),
'access arguments' => array('access content'),
);
return $items;
}
/</strong>
* Callback that displays our demo page.
*/
function foobar_demo_page() {
$output = "This is the <em>main</em> content of the current page.
The rest of the content displayed is handled by the block
system and the theme.";
// return $output;
// Enable the theme layer to alter the content.
return theme('luv_welcome_message', $output);
}
/<strong>
* theme_luv_welcome_message, the default rendering.
* this could be overridden in the a custom theme with a
* function like:
*
* function mytheme_luv_welcome_message() {
* return '<span>' . $message . '</span>';
* }
*
*/
function theme_luv_welcome_message($message) {
return '<p><strong>' . $message . '</strong></p>';
}
/</strong>
* Implementation of hook_theme
* We have to tell Drupal about our theme function so that Drupal
* can cache the information for performance reasons.
*/
function luv_theme() {
return array(
'luv_welcome_message' => array(
'arguments' => array('message' => NULL),
'file' => 'luv.page.inc',
),
);
}
/<strong>
* callback for my form
*
* These form definition is called before displaying and
* also after form submission to make sure it was not altered on the client side.
*/
function foobar_demo_form() {
// Forms are defined as arrays.
$form['first'] = array(
'#type' => 'textfield',
'#title' => t('Given name'),
'#description' => t('Please enter your first name.'),
);
$form['last'] = array(
'#type' => 'select',
'#title' => t('Last name'),
'#description' => t('Please choose one of these last names.'),
'#options' => array('Brown' => 'Brown', 'Smith' => 'Smith', 'Szabo' => 'Szabo'),
);
$form['op'] = array(
'#type' => 'submit',
'#value' => t('Calculate!'),
);
return $form;
}
/</strong>
* Process the foobar_demo_form validation
*/
function foobar_demo_form_validate($form, &$form_state) {
if ($form_state['values']['first'] == 'Longhorn') {
form_set_error('first', "Please get serious");
}
}
/**
* Process the foobar_demo_form submissions.
*/
function foobar_demo_form_submit($form, &$form_state) {
drupal_set_message($form_state['values']['first'] . ' ' . $form_state['values']['last']);
}
function luv_form_alter(&$form, $form_state, $form_id) {
// dpm($form_id);
switch ($form_id) {
case 'node_type_form':
$form['submission']['title_label']['#title'] = "George boosh title";
// dpm($form);
$form['my_bit'] = array(
'#type' => 'fieldset',
'#title' => 'Flash gordon',
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['my_bit']['this_is_serious_mum'] = array(
'#type' => 'select',
'#default_value' => 3,
'#options' => array(1 => 'Blah', 2 => 'Yay', 3 => 'Fooby'),
);
break;
}
}
?>
And the info file.
name = Demodescription = Exploring parts of the drupal API.
package = LUV
core = 6.x
No! Stole it from Halo (the
No! Stole it from Halo (the video game) (http://www.bungie.net/projects/halo3/Default.aspx)
But Coraline is cooler yes :)
#access to hide form elements
A tip that came up was setting #access to false to hide an element of a form. Quite handy to know, I think it went something like:
$form['my_bit']['this_is_serious_mum'] = array('#type' => 'select',
'#default_value' => 3,
'#options' => array(1 => 'Blah', 2 => 'Yay', 3 => 'Fooby'),
'#access' => 0,
);