本文整理汇总了PHP中CRM_Core_Form::getElement方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Form::getElement方法的具体用法?PHP CRM_Core_Form::getElement怎么用?PHP CRM_Core_Form::getElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Form
的用法示例。
在下文中一共展示了CRM_Core_Form::getElement方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
/**
* Upload and move the file if valid to the uploaded directory.
*
* @param CRM_Core_Form $page
* The CRM_Core_Form object.
* @param object $data
* The QFC data container.
* @param string $pageName
* The name of the page which index the data container with.
* @param string $uploadName
* The name of the uploaded file.
*/
public function upload(&$page, &$data, $pageName, $uploadName)
{
// make sure uploadName exists in the QF array
// else we skip, CRM-3427
if (empty($uploadName) || !isset($page->_elementIndex[$uploadName])) {
return;
}
// get the element containing the upload
$element =& $page->getElement($uploadName);
if ('file' == $element->getType()) {
if ($element->isUploadedFile()) {
// rename the uploaded file with a unique number at the end
$value = $element->getValue();
$newName = CRM_Utils_File::makeFileName($value['name']);
$status = $element->moveUploadedFile($this->_uploadDir, $newName);
if (!$status) {
CRM_Core_Error::statusBounce(ts('We could not move the uploaded file %1 to the upload directory %2. Please verify that the \'Temporary Files\' setting points to a valid path which is writable by your web server.', array(1 => $value['name'], 2 => $this->_uploadDir)));
}
if (!empty($data['values'][$pageName][$uploadName]['name'])) {
@unlink($this->_uploadDir . $data['values'][$pageName][$uploadName]);
}
$data['values'][$pageName][$uploadName] = array('name' => $this->_uploadDir . $newName, 'type' => $value['type']);
}
}
}
示例2: _volunteer_addSliderWidget
/**
* For forms which have registered as slider-enabled, add the JS and CSS necessary
* to render the slider widget(s).
*
* @param CRM_Core_Form $form
*/
function _volunteer_addSliderWidget(CRM_Core_Form &$form)
{
if (isset($form->allowVolunteerSliderWidget) && $form->allowVolunteerSliderWidget) {
$db_widgetized_fields = _volunteer_get_slider_fields();
foreach ($db_widgetized_fields as &$value) {
$value = 'custom_' . $value;
}
// Compare the global list of widget-enabled fields with the list of elements in this
// form to get a list of widget-enabled fields in this form.
$form_element_names = array_flip($form->_elementIndex);
$widgetized_fields = array_intersect($form_element_names, $db_widgetized_fields);
foreach ($widgetized_fields as $field_name) {
$css_classes = CRM_Utils_Array::value('class', $form->getElement($field_name)->_attributes);
$form->getElement($field_name)->_attributes['class'] = trim($css_classes . ' volunteer_slider');
}
if (count($widgetized_fields)) {
$ccr = CRM_Core_Resources::singleton();
$ccr->addScriptFile('org.civicrm.volunteer', 'js/slider.js');
$ccr->addStyleFile('org.civicrm.volunteer', 'css/slider.css');
}
}
}
示例3: resetElementValue
/**
* Reset values for all options those are full.
*
* @param array $optionFullIds
* @param CRM_Core_Form $form
*/
public static function resetElementValue($optionFullIds = array(), &$form)
{
if (!is_array($optionFullIds) || empty($optionFullIds) || !$form->isSubmitted()) {
return;
}
foreach ($optionFullIds as $fldId => $optIds) {
$name = "price_{$fldId}";
if (!$form->elementExists($name)) {
continue;
}
$element = $form->getElement($name);
$eleType = $element->getType();
$resetSubmitted = FALSE;
switch ($eleType) {
case 'text':
if ($element->getValue() && $element->isFrozen()) {
$label = "{$element->getLabel()}<tt>(x)</tt>";
$element->setLabel($label);
$element->setPersistantFreeze();
$resetSubmitted = TRUE;
}
break;
case 'group':
if (is_array($element->_elements)) {
foreach ($element->_elements as $child) {
$childType = $child->getType();
$methodName = 'getName';
if ($childType) {
$methodName = 'getValue';
}
if (in_array($child->{$methodName}(), $optIds) && $child->isFrozen()) {
$resetSubmitted = TRUE;
$child->setPersistantFreeze();
}
}
}
break;
case 'select':
$value = $element->getValue();
if (in_array($value[0], $optIds)) {
foreach ($element->_options as $option) {
if ($option['attr']['value'] === "crm_disabled_opt-{$value[0]}") {
$placeholder = html_entity_decode($option['text'], ENT_QUOTES, "UTF-8");
$element->updateAttributes(array('placeholder' => $placeholder));
break;
}
}
$resetSubmitted = TRUE;
}
break;
}
//finally unset values from submitted.
if ($resetSubmitted) {
self::resetSubmittedValue($name, $optIds, $form);
}
}
}
示例4: hremerg_civicrm_buildForm
/**
* @param string $formName
* @param CRM_Core_Form $form
*/
function hremerg_civicrm_buildForm($formName, &$form)
{
if ($formName == 'CRM_Contact_Form_Relationship' && empty($form->_caseId)) {
if ($form->elementExists('relationship_type_id') && $form->_contactType == 'Individual') {
$relationshipType = civicrm_api3('relationship_type', 'get', array('name_a_b' => 'Emergency Contact'));
$select = $form->getElement('relationship_type_id');
$select->freeze();
$select->setLabel('');
$form->getElement('related_contact_id')->setLabel('');
if ($form->getAction() & CRM_Core_Action::ADD && !empty($relationshipType['id'])) {
$form->setDefaults(array('relationship_type_id' => $relationshipType['id'] . '_a_b'));
}
}
}
}