Мне нужно добавить настраиваемое поле текста (навык) в разделе добавить вакансию в Orangehrm.
Я пытаюсь следующий код. Он показывает текст, поданный в форме, но не добавить в базу данных.
OrangeHRM-3,1 \ Symfony \ Plugins \ orangehrmRecruitmentPlugin \ Modules \ набор \ Шаблоны \ addJobVacancySuccess.php
Код:-
<?php
use_stylesheet(plugin_web_path('orangehrmRecruitmentPlugin', 'css/addJobVacancySuccess'));
use_javascript(plugin_web_path('orangehrmRecruitmentPlugin', 'js/addJobVacancySuccess'));
?>
<div class="box" id="addJobVacancy">
<div class="head">
<h1><?php echo isset($vacancyId) ? __('Edit Job Vacancy') : __('Add Job Vacancy'); ?></h1>
</div>
<div class="inner">
<?php include_partial('global/flash_messages'); ?>
<form name="frmAddJobVacancy" id="frmAddJobVacancy" method="post">
<?php echo $form['_csrf_token']; ?>
<?php echo $form["hiringManagerId"]->render();
?>
<fieldset>
<ol>
<li>
<?php echo $form['jobTitle']->renderLabel(__('Job Title') . ' <em>*</em>'); ?>
<?php echo $form['jobTitle']->render(array("maxlength" => 50)); ?>
</li>
<li>
<?php echo $form['name']->renderLabel(__('Vacancy Name') . ' <em>*</em>'); ?>
<?php echo $form['name']->render(array("maxlength" => 50)); ?>
</li>
<li>
<?php echo $form['hiringManager']->renderLabel(__('Hiring Manager') . ' <em>*</em>'); ?>
<?php echo $form['hiringManager']->render(array("maxlength" => 100)); ?>
</li>
<li>
<?php echo $form['noOfPositions']->renderLabel(__('Number of Positions')); ?>
<?php echo $form['noOfPositions']->render(array("maxlength" => 2)); ?>
</li>
<li class="largeTextBox">
<?php echo $form['description']->renderLabel(__('Description')); ?>
<?php echo $form['description']->render(array("cols" => 30, "rows" => 9)); ?>
</li>
<li>
<?php echo $form['skill']->renderLabel(__('Vacancy Skills') . ' <em>*</em>'); ?>
<?php echo $form['skill']->render(array("maxlength" => 50)); ?>
</li>
<li>
<?php echo $form['status']->renderLabel(__('Active')); ?>
<?php echo $form['status']->render(); ?>
</li>
<li class="labelRight">
<?php echo $form['publishedInFeed']->render(); ?>
<?php echo $form['publishedInFeed']->renderLabel(__('Publish in RSS feed(1) and web page(2)')); ?>
</li>
<?php include_component('core', 'ohrmPluginPannel', array('location' => 'add_layout_before_navigation_bar_1')) ?>
<li class="required">
<em>*</em> <?php echo __(CommonMessages::REQUIRED_FIELD); ?>
</li>
<li class="helpText">
1 : <?php echo __('RSS Feed URL') ?> : <?php echo link_to(null, 'recruitmentApply/jobs.rss', array('absolute' => true, 'target' => '_new')); ?>
</li>
<li class="helpText">
2 : <?php echo __('Web Page URL') ?> : <?php echo link_to(null, 'recruitmentApply/jobs.html', array('absolute' => true, 'target' => '_new')); ?>
</li>
</ol>
<p>
<?php if (isset($vacancyId)) { ?>
<input type="button" class="savebutton" name="btnSave" id="btnSave" value="<?php echo __("Edit"); ?>"/>
<input type="button" class="backbutton" name="btnBack" id="btnBack" value="<?php echo __("Back"); ?>"/>
<?php } else { ?>
<input type="button" class="savebutton" name="btnSave" id="btnSave"value="<?php echo __("Save"); ?>"/>
<?php } ?>
</p>
</fieldset>
</form>
</div>
<?php
if (isset($vacancyId)) {
echo include_component('recruitment', 'attachments', array('id' => $vacancyId, 'screen' => JobVacancy::TYPE));
}
?>
</div>
<script type="text/javascript">
//<![CDATA[
var hiringManagers = <?php echo str_replace(''', "'", $form->getHiringManagerListAsJson()) ?> ;
var hiringManagersArray = eval(hiringManagers);
var lang_typeForHints = '<?php echo __("Type for hints") . "..."; ?>';
var lang_negativeAmount = "<?php echo __("Should be a positive number"); ?>";
var lang_tooLargeAmount = "<?php echo __("Should be less than %amount%", array("%amount%" => '99')); ?>";
var lang_jobTitleRequired = '<?php echo __(ValidationMessages::REQUIRED); ?>';
var lang_vacancyNameRequired = '<?php echo __(ValidationMessages::REQUIRED); ?>';
var lang_enterAValidEmployeeName = "<?php echo __(ValidationMessages::INVALID); ?>";
var lang_nameExistmsg = "<?php echo __("Already exists"); ?>";
var vacancyNames = <?php echo $form->getVacancyList(); ?>;
var vacancyNameList = eval(vacancyNames);
var lang_edit = "<?php echo __("Edit"); ?>";
var lang_save = "<?php echo __("Save"); ?>";
var lang_cancel = "<?php echo __("Cancel"); ?>";
var lang_back = "<?php echo __("Back"); ?>";
var linkForAddJobVacancy = "<?php echo url_for('recruitment/addJobVacancy'); ?>";
var lang_descriptionLength = "<?php echo __(ValidationMessages::TEXT_LENGTH_EXCEEDS, array('%amount%' => 40000)) ?>";
var backBtnUrl = '<?php echo url_for('recruitment/viewJobVacancy?'); ?>';
var backCancelUrl = '<?php echo url_for('recruitment/addJobVacancy?'); ?>';
<?php if (isset($vacancyId)) { ?>
var vacancyId = '<?php echo $vacancyId; ?>';
<?php } else { ?>
var vacancyId = "";
<?php } ?>
//]]>
</script>
Попробуй это..
1) Вам необходимо создать имя поля (навык) в вашей таблице.
2) Добавьте следующие строки в orangehrm-3.1 \ symfony \ lib \ model \ doctrine \ orangehrmRecruitmentPlugin \ base \ BaseJobVacancy.class.php
Inside public function setTableDefinition(){}
$this->hasColumn('skill', 'string', 100, array(
'type' => 'string',
'length' => 100,
));
3) Добавьте следующие строки в orangehrm-3.1 \ symfony \ plugins \ orangehrmRecruitmentPlugin \ modules \ recruitment \ templates \ addJobVacancySuccess.php
Inside the form following lines
<li>
<?php echo $form['skill']->renderLabel(__('Vacancy Skills') . ' <em>*</em>'); ?>
<?php echo $form['skill']->render(array("maxlength" => 50)); ?>
</li>
4) Добавьте следующие строки в orangehrm-3.1 \ symfony \ plugins \ orangehrmRecruitmentPlugin \ lib \ form \ AddJobVacancyForm.php
Inside Widgetarray like following code
$this->setWidgets(array(
'jobTitle' => new sfWidgetFormSelect(array('choices' => $jobTitleList)),
'name' => new sfWidgetFormInputText(),
'hiringManager' => new sfWidgetFormInputText(),
......
.....
'skill' => new sfWidgetFormInputText(),
));
Inside setValidatorsarray like following code
$this->setValidators(array(
'jobTitle' => new sfValidatorString(array('required' => true)),
'name' => new sfValidatorString(array('required' => true)),
'hiringManager' => new sfValidatorString(array('required' => true)),
.....
.....
....
'skill' => new sfValidatorString(array('required' => true)),
));
Inside following code in if loop "if (isset($vacancy) && $vacancy != null) {}"
$this->setDefault('skill', $vacancy->getSkill());
Inside save() function add following following code
$jobVacancy->skill = $this->getValue('skill');
Я согласен с ответом Дины. Я создал новое поле в разделе Зарплата просто так.
Оформить заказ по ссылке
http://forum.orangehrm.com/viewtopic.php?f=6&т = 18413&ИСС = fa8d38e5b5825097a6299ef534636c93