#1 2015-07-17 19:49:49

ameera
Member
Registered: 2015-07-17
Posts: 7

! how to send checkbox list values ?

hello everyone..
i have in my form checkbox list
and when i checked more than one .. it send to the email  only the last one checked  value..
how can i send " values of  all checkbox " have chosen ?

can help me ?

Offline

#2 2015-07-19 08:08:44

ameera
Member
Registered: 2015-07-17
Posts: 7

Re: ! how to send checkbox list values ?

Anyyy reply plzzz sad
It's very important

Offline

#3 2015-07-20 12:19:43

otemu
Member
Registered: 2014-03-07
Posts: 183

Re: ! how to send checkbox list values ?

Hi,

Paste some code and we will see if we can help you, ideally form view, form config and form process.

Thanks

Offline

#4 2015-07-21 09:06:27

ameera
Member
Registered: 2015-07-17
Posts: 7

Re: ! how to send checkbox list values ?

thanks alot for reply sir

view form code :

       <form method="post" action="">
			<input type="hidden" name="form" value="order" />

                  <div class="col-lg-7 col-md-12 col-sm-12" style=" padding-right: 0;">
						<div class="col-lg-12 col-md-12 col-sm-12"><input class="form-control-proj" type="text"  name="senderName" id="senderName" value="<ion:form:order:field:senderName />" placeholder="name" /> </div>
						<div class="col-lg-6 col-md-6 col-sm-6">
							<select class="form-control-proj select" style="margin-bottom: 9px;" id="contact-way">
							  <option value="0" name="contact-way" >contact-way</option>
						
							  <option  name="contact-way" value="email"  <ion:form:order:field:select:contact-way value="email"   />  >email</option>
							  <option name="contact-way" value="whatsapp"  <ion:form:order:field:select:contact-way value="whatsapp"   /> >whatsapp</option>
							</select>
						</div>
						<div class="col-lg-6 col-md-6 col-sm-6"><input class="form-control-proj" type="text"  name="cont-details" id="cont-details" value="<ion:form:order:field:cont-details />" placeholder="cont-details" /> </div>
						<div class="col-lg-12 col-md-12 col-sm-12">
						<!-- File input -->
						<input type="file" name="file" />
						<input class="form-control-proj" type="text"  name="company" id="company" value="<ion:form:order:field:company />" placeholder="company" /> </div>
				   </div>
				   <div class="col-lg-5 col-md-5 col-sm-12 ser-type">
						<div class="col-lg-11 col-md-11 col-sm-11 type1">ser-type</div>
					
						<div class="col-lg-5 col-md-5 col-sm-11"> 
						<input type="checkbox"  name="services" id="services1"  value="services1" <ion:form:order:field:checkbox:services value="services1"   />   />         
						<label class="checkbox" for="services1"> services1</label>	</div>
						<div class="col-lg-5 col-md-5 col-sm-11">
						<input type="checkbox"  name="services" id="services2" value="services2" <ion:form:order:field:checkbox:services  value="services2"   /> />          
						<label class="checkbox" for="services2"> services2</label>	</div>
						
						<div class="col-lg-11 col-md-11 col-sm-11">
						<input type="checkbox"  name="services" id="services3" value=" services3 " <ion:form:order:field:checkbox:services  value=" services3 "   /> />                  
						<label class="checkbox" for="services3">  services3 </label>	</div>
						<div class="col-lg-11 col-md-11 col-sm-11">
						<input type="checkbox"  name="services" id="services4" value="services4 " <ion:form:order:field:checkbox:services  value="services4 "   /> />                  
						<label class="checkbox" for="services4">  services4</label>	</div>
						
					
				   </div>
					<div class="col-lg-12 col-md-12 col-sm-12">
						<textarea name="message" id="message"  class="form-control-proj msg_proj" cols="30" rows="5" height="150px" placeholder="message"><ion:form:order:field:message /></textarea> 
			
					</div>
					<div class="col-lg-12 col-md-12 col-sm-12">
						 <input class="submit_btn_proj" type="submit" value="send" />  
					</div>
                  
                  
                </form>
              </div>
            </div>

the config :

$config['forms'] = array
(
	// Contact form
	'order' => array
	(
		// The method which will process the form
		// The function name has no importance, it must only be in the declared Tagmanager class
		// and be "public static"
		'process' => 'TagManager_Contact::process_data',

		// Redirection after process. Can be 'home' or 'referer' for the $_SERVER['HTTP_REFERER'] value.
		// If not set, doesn't redirect
		'redirect' => 'referer',

		// Messages Language index, as set in language/xx/form_lang.php
		'messages' => array(
			'success' => 'form_alert_error_message',
			'error' => 'form_alert_success_message',
		),
		'emails' => array
		(
			// To Site Administrator
			array
			(

				'email' => 'contact',

				// Translation item index
				'subject' => 'new mail',

				// Used view : Located in /themes/your_theme/mail/contact.php
				'view' => 'mail/order/to_admin',
			),
			// Send to user
			array
			(
				'email' => 'form',
				'subject' => 'new email',
				'view' => 'mail/order/to_user',
			),
		),
		// Form definition: fields and rules
		'fields' => array
		(
			'senderName' => array
			(
				'rules' => 'trim|required|min_length[3]|xss_clean',
				
				
			),
			'contact-way' => array(
				'type' => 'select',
				'rules' => 'trim|xss_clean',
			),
			'cont-details' => array(
				'rules' => 'trim|required|xss_clean',
			),
			'file' => array
			(
				'rules' => 'trim|required|xss_clean',
			),
			
			'company' => array(
				'rules' => 'trim|xss_clean',
			),
			'services' => array(
                'type' => 'checkbox',
                'rules' => '',
			),
			'message' => array(
				'rules' => 'trim|xss_clean',
				
			)
		)
	),

from process

public static function process_data(FTL_Binding $tag)
	{
		// Name of the form : Must be send to identify the form.
		$form_name = self::$ci->input->post('form');

		// Because Form are processed before any tag rendering, we have to run the validation
		if (TagManager_Form::validate($form_name))
		{
			
			// upload file
			
                        $config['upload_path'] = '/uploads/';
                        $config['allowed_types'] = 'gif|jpg|png';
                        
                        //NEW
                        $config['allowed_extensions'] = array('gif', 'jpg', 'png');

						$config['max_size']	= '1000';
						$config['max_width'] = '1024';
						$config['max_height'] = '768';

						self::$ci->load->library('upload', $config);
						self::$ci->upload->do_upload();
						if( ! self::$ci->upload->do_upload() )
						{
							// Upload aborted: Add one custom error message
							$message = TagManager_Form::get_form_message('error');
							TagManager_Form::set_additional_error($form_name, self::$ci->upload->display_errors('<p>', '</p>'));
						}			
						else
						{
							// Upload successfull
							$data = array_merge($post, self::$ci->upload->data());
							TagManager_Email::send_form_emails($tag, $form_name, $data);
						}
			//// end upload code 

			$go_further = TRUE;
			$results = Event::fire('Form.contact.check', $post);

			if (is_array($results))
			{
				foreach($results as $result)
					if ( ! $result)
						$go_further = FALSE;
			}

			if ($go_further)
			{
			
				TagManager_Email::send_form_emails($tag, $form_name, $post);
				$message = TagManager_Form::get_form_message('success');
				TagManager_Form::set_additional_success($form_name, $message);
			}

			$redirect = TagManager_Form::get_form_redirect();
			if ($redirect !== FALSE) redirect($redirect);
		}

send email code :

<table border="0" width="100%" cellpadding="0" cellspacing="0">
	<tr>
		<td class="bg_fade">
			<table border="0" width="880">
				<tr>
					<td>
						<p>new email</p>

						<p>
							<b>name</b> : <ion:data:senderName/><br/>
							<b>contact details</b> : <ion:data:cont-details /><br/>
							
						</p>
						<p>
							<b>company</b> :<ion:data:company />
						</p>
						<p>
							<b>service</b> : <ion:data:services[] />
							<b>file uploaded</b> : <ion:data:file />
							<b>details</b> : <ion:data:message />
						</p>
					</td>
				</tr>
			</table>
		</td>
	</tr>
</table>

-----
code send email with only the last one checked  value
and the file doesn't upload and send erorr in email

can you help me please ?
i can send you hosting account to try it in online if you want

Offline

#5 2015-07-23 08:15:57

iforwms
Member
From: Yangshuo, Guilin
Registered: 2015-07-23
Posts: 1
Website

Re: ! how to send checkbox list values ?

You're only posting the last value because they are being overwritten. You need to save the checkboxes as an array of values, like this: <input type="checkbox"  name="services[]">

By adding [] to the end of each checkbox name, you will get an array of values once the form is posted.

Offline

#6 2016-04-08 16:38:32

fredericomarinho.com
Member
From: Juiz de Fora / Brazil
Registered: 2015-06-08
Posts: 40
Website

Re: ! how to send checkbox list values ?

But how to send this through an email?

Same problem here


Frederico Marinho - Social Media and Web Developer
contato@fredericomarinho.com
fredericomarinho.com

Offline

What's Ionize ?

Ionize is an Open Source Content Management System created by webdesigners for webdesigners.

Created and maintained by Partikule and Toopixel, Ionize wants to be the easiest and most powerful CMS.

Can I help ?

Because talent is nothing without involvement, we are looking for motivated coders and webdesigners to join the project team.

Resources

Website : ionizecms.com
Documentation : doc.ionizecms.com

Development : Ionize on GitHub
Translations : Ionize Translations