barebones for a couple of fields

master
Marek Isalski 9 years ago
parent dbfaa19328
commit 991369e91d

@ -1,10 +1,10 @@
<?php <?php
function fulcrm_collection_permission() { function fulcrm_collection_permission() {
return array( 'administer fulcrm collection' => array( 'title' => t('Administer fulcrm collection'), return array( 'administer fulcrm collection' => array( 'title' => t('Administer fulcrm collection'),
'description' => t('Perform main installation/administration tasks for fulcrm collection.'), 'description' => t('Perform main installation/administration tasks for fulcrm collection.'),
), ),
); );
} }
function fulcrm_collection_menu() { function fulcrm_collection_menu() {
@ -20,12 +20,52 @@ function fulcrm_collection_menu() {
); );
*/ */
$items[ 'admin/config/services/fulcrm/collection' ] = array( 'page callback' => 'fulcrm_collection_admin', $items[ 'admin/config/services/fulcrm/collection' ] = array( 'page callback' => 'fulcrm_collection_admin',
'file' => 'fulcrm_collection.admin.inc', 'file' => 'fulcrm_collection.admin.inc',
'title' => 'fulcrm Shopping Cart', 'title' => 'fulcrm Shopping Cart',
'description' => 'Configure collection for fulcrm.org.', 'description' => 'Configure collection for fulcrm.org.',
'access callback' => 'user_access', 'access callback' => 'user_access',
'access arguments' => array('administer fulcrm collection'), 'access arguments' => array('administer fulcrm collection'),
); );
return $items; return $items;
} }
function fulcrm_collection_to_form( $collection_data, $d = array() ) {
$form = array();
foreach ( $collection_data[ '_structure' ] as $set_data ) {
switch ( $set_data[ 'type' ] ) {
case 'ddataset':
$fieldset = array( '#type' => 'fieldset',
'#title' => $set_data[ 'name' ],
'#description' => $set_data[ 'description' ],
);
foreach ( $set_data[ 'fields' ] as $field_data ) {
switch ( $field_data[ 'type' ] ) {
case 'text':
case 'email':
case 'tel':
$fieldset[ $field_data[ 'key' ] ] = array( '#type' => 'textfield',
'#title' => $field_data[ 'name' ],
'#description' => $field_data[ 'description' ],
'#required' => $field_data[ 'required' ],
);
break;
default:
drupal_set_message( t('Cannot handle ":type" collection structure.', array( ':type' => $field_data[ 'type' ] )), 'error' );
break;
}
}
$form[] = $fieldset;
break;
default:
drupal_set_message( t('Cannot handle ":type" collection structure.', array( 'type' => $set_data[ 'type' ] )), 'error' );
break;
}
}
return $form;
}

Loading…
Cancel
Save