Thanks In advance
I want Add New Attachment Field before the comment field in leaveplugin In apply leave form How i do please tell step vise
Add this in
getFormWidgets()-
'attach' => new sfWidgetFormInputFileEditable(array('edit_mode' => false,'with_delete' => false, 'file_src' => ''))
Add following code in
getFormValidators() function -
'attach' => new sfValidatorFile(array('required' => false, 'max_size' => 1024000, 'validated_file_class' => 'orangehrmValidatedFile'))
In action class, bind that form with $request->getFiles().
How to add fields in candidate form
First add all threee field in #_job_candidate table
orangehrm\symfony\plugins\orangehrmRecruitmentPlugin\lib\form\AddCandidateForm.php
orangehrm\symfony\plugins\orangehrmRecruitmentPlugin\modules\recruitment\templates\addCandidateSuccess.php
orangehrm\symfony\lib\model\doctrine\orangehrmRecruitmentPlugin\base\BaseJobCandidate.class.php
but all data is not Inserted in database
Related
This has been driving me nuts for 2 days and I can't find an answer anywhere on Google so would really appreciate a little help..
I have a custom registration form on my website, which sends the data to a fairly standard PHPBB3 user_add process as follows:
$user_row = array(
'username' => request_var('createUsername',''),
'user_password' => phpbb_hash(request_var('createPassword','')),
'user_email' => request_var('createEmail',''),
'group_id' => '2',
'user_timezone' => '1.00',
// 'user_dst' => '0',
'user_lang' => 'en',
'user_type' => $user_type,
'user_actkey' => $user_actkey,
'user_ip' => $user->ip,
'user_regdate' => time(),
'user_inactive_reason' => $user_inactive_reason,
'user_inactive_time' => $user_inactive_time,
);
// Register user...
$user_id = user_add($user_row, $cp_data);
// If creating the user failed, display an error
if ($user_id === false)
{
trigger_error('NO_USER', E_USER_ERROR);
}
That works fine and I'm happy with it, however, I have created a custom profile field in the Admin Control Panel called 'ea_real_name' which I want to hold the user's real name. This corresponds to a field on the registration form called 'createRealName' (sent through as $_POST['createRealName'])
I know that user_add takes an optional field called 'cp_data', but I can't for the life of me work out how to format this data... Should it be an array (something like 'ea_real_name' => request_var('createRealName','') or something else?
PHPBB's wiki for the field is empty (https://wiki.phpbb.com/Custom_profile::submit_cp_field) so not much help...
Thanks! :-)
I was right in my assumption! It's an array with the field name prefixed by pf_.
Finally found an answer here: https://www.phpbb.com/community/viewtopic.php?f=71&t=1638905
$cp_data = array(
'pf_ea_real_name' => request_var('createRealName','')
);
Is the correct way to do it...
I am new to ROR and spent most of the day trying to get this to work. I have tried using the before_filter and I cannot get my object to insert in another method.
The view is index, a file is selected in the view and then the button to validate file is clicked which calls a method 'evaluate_media' in this method, I look up values based on the file path and name selected and I can successfully insert the record with all the values in this method. The problem is I don't want an automatic save. When the 'evaluate_media' method is done it displays back with either a save button or an update button based on if the file submitted already exists in the database. Then the user can choose to save/update the record or now. This button calls the 'save_file' action. The problem is all the information save in 'evaluate_media' action for the file is not accessible to save_file or update_file actions. I believe session variables might be my answer but I could not find any good examples to get it setup correctly and working in my application. Can someone please tell me and show me the proper code to pass the value from 'evaluate_media' action to save_file or update_file actions?
Here is the code where I assign the values for a new record in my evaluaate_media method:
if #file_exists_flag == 'NEW'
# Assign Parameter values for new save
#file_alias_tfile = FileAliasTfile.new( {:src_location => #radio_button_value, :directory => #dir_path_choice, :full_path => #selected_filepath, :full_filename => #filepath, :file_ext => '',
:assigned_status => 'Unassigned', :file_status => 'Saved', :alias_code => #file_alias.to_s, :validate_status => #file_status.to_s, :error_msg => #file_msg.to_s,
:video_alias_match => #msg_dtl1.to_s, :audio_alias_match => #msg_dtl2.to_s, :video_format => #video_format.to_s, :video_bitrate => #video_bitrate.to_s,
:video_width => #video_width.to_s,
:video_height => #video_height.to_s, :video_framerate => #video_framerate.to_s, :video_aspect_ratio => #video_aspectratio.to_s, :video_scan_type => #video_scantype.to_s,
:video_scan_order => #video_scanorder.to_s, :video_alias_code => '', :audio_alias_code => '', :bus_prod_initiative_id => 0, :status => 'Active', :start_date => DateTime.now.to_date,
:end_date => '', :deleted_b => 0, :created_by => 'admin', :updated_by => 'admin'} )
end
Then if the user clicks the save, the save_file method is called and here is the code to save the
values from evaluate_media into the database:
def save_file
#file_alias_tfile = FileAliasTfile.create(#file_alias_tfile)
#file_alias_tfile.save
end
I figure the update will be the same as the save so I only included one case here.
Your help is appreciated. Thank you!
First of all,
def save_file
#file_alias_tfile = FileAliasTfile.create(#file_alias_tfile)
#file_alias_tfile.save
end
ModelName.create() is equivalent to ModelName.new(....).save. So the second line should be deleted.
You could do this:
if #file_exists_flag == 'NEW'
session[:my_file] = FileAliasTfile.new( .... )
def save_file
session[:my_file].save
end
However, generally it's not recommended to save model objects in the session. Instead, you should save the object in the database; then save the id of the object in the session. I know, "But I don't want to save the object in the database until the user confirms". Have you ever heard of the destroy() method? For instance,
FileAlias.destroy(session[:file_id])
which deletes the record in the file_aliases table with an id equal to session[:file_id].
When the 'evaluate_media' method is done it displays back with either
a save button or an update button based on if the file submitted
already exists in the database.
So, create() the record (remember that saves the record), and if the user clicks the save button, do nothing. If the user clicks the update button, then delete the record from the database and delete the id from the session. For example:
if #file_exists_flag == 'NEW'
my_file = FileAlias.create( .... )
session[:file_id] = my_file.id
def save_file
#render some page
end
def update_file
my_file = FileAlias.destroy(session[:id])
session.delete[:file_id]
#Do something with my_file?
end
Is it possible to add new custom editable fields to the module Peronal data? If so, how does this work? PHP my admin and add Mysql tables? Or can this be done via the contao backend? Please advise
Its very much possible. I am not sure which contao version you are using now because they differ in how you create the database field.
Lets assume you want to add accept terms checkbox to the registration module.
Contao 2.11
In modules directory create a folder with the following structure
myModule/config/database.sql
myModule/dca/tl_member.php
myModule/languages/en/tl_member.php
In database.sql, create the field as follows
CREATE TABLE `tl_member` (
accept_terms char(1) NOT NULL default '',
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
In dca/tl_member.php, add the field to tl_member dca close to where login details are as follows.
$GLOBALS['TL_DCA']['tl_member']['palettes']['default'] = str_replace('login;','login,accept_terms;',$GLOBALS['TL_DCA']['tl_member']['palettes']['default']);
Create the field as follows(used to generate the checkbox input)
$GLOBALS['TL_DCA']['tl_member']['fields']['accept_terms'] = array(
'label' => &$GLOBALS['TL_LANG']['tl_member']['accept_terms'],
'inputType' => 'checkbox',
'eval' => array( 'mandatory' => true, 'tl_class' => 'w50', 'feEditable' => true,'feViewable'=>true)
);
Note:
mandatory => true // make it a mandatory field
feEditable => true // enable edit in module personal data or module registration
feViewable=>true // make it appear in module personal data or module registration
in languages/en/tl_member.php, create the labels as follows
$GLOBALS['TL_LANG']['tl_member']['accept_terms'] = array('Terms & Conditions', 'I accept the terms and conditions of using this website.');
Contao 3
The structure is pretty much the same only that you don't need the database.sql i.e you can remove it and modify dca/tl_member.php as follows
$GLOBALS['TL_DCA']['tl_member']['fields']['accept_terms'] = array(
'label' => &$GLOBALS['TL_LANG']['tl_member']['accept_terms'],
'inputType' => 'checkbox',
'eval' => array( 'mandatory' => true, 'tl_class' => 'w50', 'feEditable' => true,'feViewable'=>true),
'sql' => "char(1) NOT NULL default ''"
);
Note the addition of this line 'sql' => "char(1) NOT NULL default ''" in the array.
Now go to the install tool and create your field in mysql. login to the backend, go to modules, your personal data module and you should be able to see your field there. Check it to include it to frontend fields and you are done.
Please not the consistency of using tl_member and accept_terms in all the directories
hi all when clicking the link on my page its not carrying the id from the template when going to the view page, so when the sql queries the database it is querying this
SELECT `Field`.`name`
FROM `pra`.`fields` AS `Field`
LEFT JOIN `pra`.`templates` AS `Template` ON (
`Field`.`template_id` = `Template`.`id`)
WHERE `template`.`id` IS NULL
the database says id should be = 2
here is the code for the view function
$fields = $this->Field->find('all',
array('fields'=>array('name','template_id'),
'conditions' => array('template_id' => $this->Auth->user('template.id'))));
$this->set('field', $fields);
updated code, the template_id still equals null
when hardcoded it works correctly, there is a problem with this line $this->Auth->user
You can try with the following code:
$fields = $this->Field->find('all',
array('fields'=>array('name'),
'conditions' => array('Field.template_id' => $this->Auth->user('template_id'))
)
);
$this->set('field', $fields);
Please be sure there must have any template_id value should be there for the current logged in user.
Kindly ask if it not worked for you.
Check the result of the find call, by doing a debug:
debug($fields);
This will show you the returned data from the query. You can add this to the end of your action method.
If the results are empty, double check the values that are stored in the session Auth key. You can do this by dumping out the session with debug($_SESSION) or use the CakePHP DebugKit. The Debug Kit offers you a small toolbar at the top right of the screen and lets you view session information and such.
function view($name){
$this->set('title_for_layout', 'Create Template');
$this->set('stylesheet_used', 'homestyle');
$this->set('image_used', 'eBOXLogoHome.jpg');
$this->layout='home_layout';
$fields = $this->Template->Field->find('list',array(
'fields'=> array('name'),
'conditions' => array(
'template_id'=> $name)));
$this->set('field', $fields);
}
it wasn't passing the param's value
Hi can you please tell how can i validate the multiple checkbox any one is checked in yii framework
array('accept', 'required', 'requiredValue' => 1, 'message' => 'You should select alteast one')
As these value are usually sent as arrays, I wrote an array validator for these cases once: https://github.com/schmunk42/p3extensions/blob/master/validators/P3ArrayValidator.php
Usage example:
array('accept',
'ext.validators.P3ArrayValidator',
'min'=>1,
'allowEmpty'=>false,
'message' => 'You should select at least one'
),
sorry for the late reply.
But, I found a solution without installing any extension.
Take a hidden field with the same name [Checkboxes list field].
<?php echo $form->hiddenField($model,'categories');?>
Display a list of categories with name different from our field name (multiple checkboxes).
But, remember the 'class', and play with the class to save the values.
<?php
echo CHtml::checkBoxList(
'group',
//you can pass the array here which you want to be pre checked
explode(',', trim($model->attributes['categories'], ',')),
CHtml::listData(Category::model()->findAll(),'id','name'),
array('separator'=>'', 'template'=>'<tr><td style="width:5%;">{input}</td><td>{label}</td></tr>', 'class' => 'group')
);
?>
This way validation should work also, you get category ids as comma separated e.g. [,1,2,6,]
<script>
$(function(){
$(".group").click(function(){
var str = $('.group:checked').map(function() {
return this.value;
}).get().join();
var groupCats = (str.length > 0) ? ','+str+',' : '';
$('#ModelNAME_field').val(groupCats);
// Get the 'ModelNAME_field' by viewing source of HTML of hidden field.
});
});
</script>