Skip to content

Commit

Permalink
filled dropdown with values
Browse files Browse the repository at this point in the history
  • Loading branch information
David Zaremba committed Aug 26, 2020
1 parent b04d990 commit c7c626a
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions plugins/workflow/fields/fields.php
Expand Up @@ -13,7 +13,7 @@
use Joomla\CMS\Event\Workflow\WorkflowFunctionalityUsedEvent;
use Joomla\CMS\Event\Workflow\WorkflowTransitionEvent;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Form;
use Joomla\CMS\Form\Field\SubformField;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\DatabaseModelInterface;
use Joomla\CMS\Plugin\CMSPlugin;
Expand Down Expand Up @@ -96,41 +96,27 @@ public function onContentPrepareForm(EventInterface $event)

$existingFields = FieldsHelper::getFields($workflow->extension);

// build subform
$subform = simplexml_load_file(JPATH_ROOT.'/plugins/workflow/fields/forms/subform.xml');
$myfield = $subform -> fields -> addChild('field');
$myfield->addAttribute('name','customfield');
$myfield->addAttribute('type','list');

// add all existing Custom Fields as option to field
foreach ($existingFields as $existingField){
$option = $myfield->addChild('option');
$option = $myfield->addChild('option',$existingField->name);
$option -> addAttribute('value', $existingField->id);
}
for ($i = 0; $i < count($form->getXml()->fields);$i++){
$attributes = $form->getXml()->fields[$i]->fieldset->attributes();
if(!strcmp($attributes['name'],"fields")) {
$form->getXml()->fields[$i]->fieldset->field->formsource=$subform->fields->asXML();
}
}
//$form->getXml()->fields[3]->fieldset->field->formsource=$subform->fields->asXML();

//$form->load($subform,false);
$form->setFieldAttribute('subform','formsource',$subform->asXML(),'options');


return;
}

return;

}
/*protected function enhanceWorkflowTransitionForm(Form $form, $data)
{
$workflow = parent::enhanceWorkflowTransitionForm($form, $data);
//
return $workflow;
}*/



/**
* Check if we can execute the transition
Expand Down Expand Up @@ -163,7 +149,9 @@ public function onWorkflowBeforeTransition(WorkflowTransitionEvent $event)

if (!$this->isSupported($context)
||!is_numeric($reqired)
||!is_numeric($blankreqired))
||!is_numeric($blankreqired)
||!is_numeric($contains)
||!is_numeric($containsNot))
{
return true;
}
Expand Down

0 comments on commit c7c626a

Please sign in to comment.