8 $widget =&
$field[
'widget'];
10 if ( !@$widget[
'separator'] ) $widget[
'separator'] =
'<br />';
13 (isset($field[
'transient']) and isset($field[
'relationship']) )){
16 if ( @$field[
'vocabulary'] ){
19 }
else if ( isset($field[
'relationship']) ){
20 $relationship =& $record->_table->getRelationship($field[
'relationship']);
21 $options = $relationship->getAddableValues($record);
22 $options__classes = array();
26 if ( !@$widget[
'suffix'] ) $widget[
'suffix'] =
'';
28 if ( !
PEAR::isError($dtable) and $record->checkPermission(
'add new related record', array(
'relationship'=>$relationship->getName()) )){
31 $suffix =
'<script type="text/javascript" src="'.DATAFACE_URL.
'/js/jquery-ui-1.7.2.custom.min.js"></script>';
32 $suffix .=
'<script type="text/javascript" src="'.DATAFACE_URL.
'/js/RecordDialog/RecordDialog.js"></script>';
33 $suffix .=
'<a href="#" onclick="return false" id="'.htmlspecialchars($field[
'name']).
'-other">Other..</a>';
35 $(\'head\').append(\'<link rel="stylesheet" type="text/css" href="\'+DATAFACE_URL+\'/css/smoothness/jquery-ui-1.7.2.custom.css"/>\');
36 jQuery(document).ready(function($){
37 $("#'.$field[
'name'].
'-other").each(function(){
38 var tablename = "'.addslashes($dtable->tablename).
'";
39 var fldname = "'.addslashes(htmlspecialchars($field[
'name'])).
'";
40 var keys = '.json_encode(array_keys($dtable->keys())).
';
42 $(this).RecordDialog({
44 callback: function(data){
46 for ( var i=0; i<keys.length; i++){
47 val.push(encodeURIComponent(keys[i])+\'=\'+encodeURIComponent(data[keys[i]]));
49 val = val.join(\'&\');
50 fldname = tablename+\'[\'+val+\']\';
53 $(btn).before(\'<input type="checkbox" name="\'+fldname+\'" value="\'+val+\'" checked="1"/>\'+data["__title__"]+\'<br/>\');
60 $widget[
'suffix'] = $suffix;
65 if ( $record and $record->val($field[
'name']) ){
66 $vals = $record->val($field[
'name']);
67 if ( is_array($vals) ){
68 foreach ( $vals as $thisval){
69 if ( !isset($options[$thisval]) ){
70 $options[$thisval] = $thisval;
76 $dummyForm =
new HTML_QuickForm();
77 foreach ($options as $opt_val=>$opt_text){
78 if ( !$opt_val )
continue;
79 $boxes[] =& $dummyForm->createElement(
'checkbox',$opt_val , null, $opt_text, array(
'class'=>
'checkbox-of-'.$field[
'name'].
' '.@$options__classes[$opt_val]));
83 $el =& $factory->addGroup($boxes, $field[
'name'], $widget[
'label']);
89 $el =& $factory->addElement(
'advcheckbox', $formFieldName, $widget[
'label']);
90 if ( $field[
'vocabulary'] ){
93 if (
$table->isYesNoValuelist($field[
'vocabulary'], $yes, $no) ){
94 $el->setValues(array($no,$yes));
102 $table =& $record->_table;
104 $formFieldName = $element->getName();
106 $val = $element->getValue();
111 if ( is_array($val) ){
112 $out = array_keys($val);
118 if ( preg_match(
'/int/', @
$field[
'Type']) ){
128 'scripts.Dataface.QuickForm.pushValue.ERROR_PUSHING_VALUE',
129 "Error pushing value for field '$field[name]' in QuickForm::pushWidget() on line ".__LINE__.
" of file ".__FILE__,
130 array(
'name'=>
$field[
'name'],
'file'=>__FILE__,
'line'=>__LINE__)
150 $formFieldName = $element->getName();
151 $raw =& $record->getValue(
$field[
'name']);
152 if (
$field[
'repeat'] and is_array($raw)){
156 foreach ($raw as $key=>$value){
171 $val = $record->getValueAsString(
$field[
'name']);