advpoll_field.install in Advanced Poll 7
Same filename and directory in other branches
File
advpoll_field/advpoll_field.installView source
<?php
/*
* Custom field widget used by Advanced poll to link write-in flag to each available choice.
*
* Note: choice_id is necessary as a hidden field to provide a related unique value for each
* choice field. Each time a choice is removed or reordered, its delta is reset, as is the
* array provided in the node data. As a result, simply passing an index to the votingapi as
* the id for a given choice proved inadequate in cases where choice delta changes due to
* content editing or write-in values being merged.
*
* Initially I had planned to use an auto-incrementing primary key field but this does not
* work with the custom field API, hence I settled for this solution.
* The unique value is just a randomized timestamp that has been converted to hex for brevity.
*/
function advpoll_field_field_schema($field) {
$columns = array(
'choice_id' => array(
'type' => 'varchar',
'length' => 10,
'not null' => TRUE,
),
'choice' => array(
'type' => 'varchar',
'length' => 500,
'not null' => TRUE,
),
'write_in' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
);
$indexes = array(
'choice' => array(
'choice',
),
);
return array(
'columns' => $columns,
'indexes' => $indexes,
);
}
Functions
Name | Description |
---|---|
advpoll_field_field_schema |