我创建了一个webform处理程序,它正在创建节点并适当地传递所有内容,除了一个webform字段(字段'Apply')中的url。
你知道我做错了什么吗?下面是处理程序的代码。
class HRJobWebformHandler extends WebformHandlerBase {
public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
$values = $webform_submission->getData();
$pos_org = $values['position'] . "-" . $values['organization'];
$node_args = [
'type' => 'job_posting',
'langcode' => 'en',
'created' => time(),
'changed' => time(),
'uid' => 1,
'title' => $pos_org,
'field_salary_information' => $values['salary_information'],
'field_apply' => [
'uri' =>$values['apply']
],
'field_more_information' => $values['more_information'],
'field_position' => $values['position'],
'field_organization' => $values['organization'],
'field_area' => $values['area'],
'field_job' => [
'value' => $values['job_description'],
'format' => 'full_html'
]
];
$node = Node::create($node_args);
$node->setPublished(false);
$node->save();
}
}
问题解决:Webform将Apply
字段数据作为数组(这是一个URL字段)发布。代码更改为UPDATE: Webform post将Apply
链接作为数组传递。代码改为:
'uri' =>$values['apply']['url']