Fedex form Error - php

This is the HTML form when i submit the form it gives the following error
Fatal error: Uncaught SoapFault exception: [WSDL] SOAP-ERROR: Parsing WSDL: Couldn't load from
'../../../wsdl/ShipService_v17.wsdl' : failed to load external entity
"../../../wsdl/ShipService_v17.wsdl" in
D:\Hosting\10722104\html\fedex\php\ShipWebServiceClient\Express\Domestic\ShipWebServiceClient.php5:17
Stack trace: #0
D:\Hosting\10722104\html\fedex\php\ShipWebServiceClient\Express\Domestic\ShipWebServiceClient.php5(17):
SoapClient->SoapClient('../../../wsdl/S...', Array) #1 {main} thrown
in
D:\Hosting\10722104\html\fedex\php\ShipWebServiceClient\Express\Domestic\ShipWebServiceClient.php5
on line 17
` <form id="form1" method="post" action="php/ShipWebServiceClient/Express /Domestic/ShipWebServiceClient.php5">
<div class="from_box">
<div class="top_from_hed">Fill out this Form to Get<br />FREE <img src="images/fed-ex-butoon.png" />Shiping! </div>
<div class="all_felds">1. What are you sending?<br />
<input name="" type="checkbox" value=""onclick="showfirstbox(); " name="sending" /> Diamond <input name="" type="checkbox" value="" /> Gold <input name="" type="checkbox" value="" /> Silver <br />
<br /><br />
<input type="radio" name="printll" id="secondbox" />Print label
<table width="259" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="91" height="29">First Name:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="fname" id="textfield" />
</label>
</form> </td>
</tr>
<tr>
<td width="91" height="28">Last Name:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="lname" id="textfield" />
</label>
</td>
</tr>
<tr>
<td width="91" height="27">Street Address:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="street" id="textfield" />
</label>
</td>
</tr>
<tr>
<td width="91" height="27">Email Address:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="eeemail" id="textfield" />
</label>
</td>
</tr><tr>
<td width="91" height="28">Apt/Suite:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="textfield" id="textfield" />
</label>
</td>
</tr><tr>
<td width="91" height="27">City:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="city" id="textfield" />
</label>
</td>
</tr><tr>
<td width="91" height="27">Country:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="country" id="textfield" />
</label>
</td>
</tr><tr>
<td width="91" height="27">State:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="state_hid" id="textfield" />
</label>
</td>
</tr><tr>
<td width="91" height="28">Zip Code:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="postalcode" id="textfield" />
</label>
</td>
</tr>
<tr>
<td width="91" height="26">Phone no:</td>
<td width="10"> </td>
<td width="162">
<label>
<input type="text" name="phone" id="textfield" />
</label>
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><table width="157" height="19" border="0" cellpadding="0" ce llspacing="0">
<tr>
<td width="30"> </td>
<td width="74"><div class="submit_from_hed">
<a href="#"><font color="#333333">
<input type="submit"name="fdesubmit" value="submit" /></font></a>
</div></td>
<td width="53"> </td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><table width="156" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="28"> </td>
<td width="128"> </td>
</tr>
</table></td>
</tr>
</table>`
This is the code i am using for fedex form integration
`<?php
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0
require_once('../../../library/fedex-common.php5');
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "../../../wsdl/ShipService_v17.wsdl";
define('SHIP_LABEL', time() . '.png'); // PNG label file. Change to file-extension .pdf for creating a PDF label (e.g. shiplabel.pdf)
ini_set("soap.wsdl_cache_enabled", "0");
ini_set("soap.wsdl_cache", "0");
ini_set("display_errors","On");
ini_set("track_errors","On");
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
$name='';
$invoice_num='INV' . time() * 3;
$option=$_REQUEST['option'];
$request['WebAuthenticationDetail'] = array(
'UserCredential' =>array(
'Key' => getProperty('key'),
'Password' => getProperty('password')
)
);
$request['ClientDetail'] = array(
'AccountNumber' => getProperty('shipaccount'),
'MeterNumber' => getProperty('meter')
);
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Express Domestic Shipping Request using PHP ***');
$request['Version'] = array(
'ServiceId' => 'ship',
'Major' => '10',
'Intermediate' => '0',
'Minor' => '0'
);
$request['RequestedShipment'] = array(
'ShipTimestamp' => date('c'),
'DropoffType' => 'REGULAR_PICKUP',
'ServiceType' => 'FEDEX_EXPRESS_SAVER',
'PackagingType' => 'YOUR_PACKAGING',
'Shipper' => addShipper(),
'Recipient' => addRecipient(),
'ShippingChargesPayment' => addShippingChargesPayment(),
'SpecialServicesRequested' => addSpecialServices(),
'LabelSpecification' => addLabelSpecification(),
'PackageCount' => 1,
'RequestedPackageLineItems' => array(
'0' => addPackageLineItem1()
)
);
try {
if(setEndpoint('changeEndpoint')){
$newLocation = $client->__setLocation(setEndpoint('endpoint'));
}
$response = $client->processShipment($request); // FedEx web service invocation
if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR'){
printSuccess($client, $response);
$fp = fopen('../label/' . SHIP_LABEL, 'wb');
fwrite($fp, $response->CompletedShipmentDetail->AssociatedShipments->Label->Parts->Image); //Create COD Return PNG or PDF file
fclose($fp);
$message1="Transaction Successful<br>";
if($option==$_POST['printll'])
{
$link=SHIP_LABEL;
$message='<div id="label1" style="margin-bottom:-10px;">
<div id="number"></div>
<div id="message"> <h3 style="color:#666;">Click here to print your label</h3>
</div>
</div>';
$message.='<div id="label1">
<div id="second"> </div>
</div>';
$message.='<div id="label1">
<div id="third"></div>
</div>';
}
}else{
writeToLog($client); } // Write to log file
}
catch (SoapFault $exception) {
printFault($exception, $client);
}
function addShipper(){
$name=$_POST['fname'] . " " . $_POST['lname'];
$shipper = array(
'Contact' => array(
'PersonName' => $name,
'CompanyName' => '',
'PhoneNumber' => $_POST['phone'],
'Email' => $_POST['eeemail'],
),
'Address' => array(
'StreetLines' => array($_POST['street']),
'City' => $_POST['city'],
'StateOrProvinceCode' => $_REQUEST['state_hid'],
'PostalCode' => $_REQUEST['postalcode'],
'CountryCode' => $_REQUEST['country'])
);
return $shipper;
}
function addRecipient(){
$recipient = array(
'Contact' => array(
'Contact' => array(
'PersonName' => 'CRJ Inc',
'CompanyName' => 'CRJ Inc c/o NDB',
'PhoneNumber' => '800-574-8820'),
'Address' => array(
'StreetLines' => array('4010 Oak Circle'),
'City' => 'Boca Raton',
'StateOrProvinceCode' => 'FL',
'PostalCode' => '33431',
'CountryCode' => 'US',
'Residential' => false)
)
) ;
return $recipient ;
}
function addShippingChargesPayment(){
$shippingChargesPayment = array('PaymentType' => 'SENDER',
'Payor' => array(
'ResponsibleParty' => array(
'AccountNumber' => getProperty('billaccount'),
'Contact' => null,
'Address' => array(
'CountryCode' => 'US')
)
)
);
return $shippingChargesPayment;
}
function addLabelSpecification(){
$labelSpecification = array(
'LabelFormatType' => 'COMMON2D', // valid values COMMON2D, LABEL_DATA_ONLY
'ImageType' => 'PNG', // valid values DPL, EPL2, PDF, ZPLII and PNG
'LabelStockType' => 'PAPER_7X4.75'
);
return $labelSpecification;
}
function addSpecialServices1(){
$specialServices = array(
'SpecialServiceTypes' => array('COD'),
'CodDetail' => array(
'CodCollectionAmount' => array(
'Currency' => 'USD',
'Amount' => 150
),
'CollectionType' => 'ANY' // ANY, GUARANTEED_FUNDS
)
);
return $specialServices;
}
function addCustomClearanceDetail(){
$customerClearanceDetail = array(
'DutiesPayment' => array(
'PaymentType' => 'SENDER', // valid values RECIPIENT, SENDER and THIRD_PARTY
'Payor' => array(
'AccountNumber' => getProperty('dutyaccount'),
'CountryCode' => 'CA'
)
),
'DocumentContent' => 'NON_DOCUMENTS',
'CustomsValue' => array(
'Currency' => 'USD',
'Amount' => 20.0
),
'Commodities' => array(
'0' => array(
'NumberOfPieces' => 1,
'Description' => 'Books',
'CountryOfManufacture' => 'US',
'Weight' => array(
'Units' => 'LB',
'Value' => 1.0
),
'CustomsValue' => array(
'Currency' => 'USD',
'Amount' => 20.000000
)
)
),
'ExportDetail' => array(
'B13AFilingOption' => 'NOT_REQUIRED'
)
);
return $customerClearanceDetail;
}
function addPackageLineItem1(){
$packageLineItem = array(
'SequenceNumber'=>1,
'GroupPackageCount'=>1,
'InsuredValue' => array(
'Amount' => 20.00,
'Currency' => 'USD'
),
'Weight' => array(
'Value' => 1.0,
'Units' => 'LB'
),
'Dimensions' => array(
'Length' => 20,
'Width' => 10,
'Height' => 10,
'Units' => 'IN'
),
'CustomerReferences' => array(
'0' => array(
'CustomerReferenceType' => 'CUSTOMER_REFERENCE',
'Value' => 'GR' . time() * 7
), // valid values CUSTOMER_REFERENCE, INVOICE_NUMBER, P_O_NUMBER and SHIPMENT_INTEGRITY
'1' => array(
'CustomerReferenceType' => 'INVOICE_NUMBER',
'Value' => $invoice_num
),
'2' => array(
'CustomerReferenceType' => 'P_O_NUMBER',
'Value' => 'PO' .time() * 5
)
)
);
return $packageLineItem;
}
?>
`
Please find me some solution for this so that i would be able to create labels from the website

Related

Prestashop 1.7.5.2 How to add manually the customer vat_number on invoice

I need to add the customer delivery and billing vat_number on the invoice generated by prestashop.
I've tryed to modify my classes/pdf/HTMLTemplateInvoice.php adding 'customer_vat_number' => $invoice_address->vat_number like that:
$data = array(
'order' => $this->order,
'order_invoice' => $this->order_invoice,
'order_details' => $order_details,
'carrier' => $carrier,
'cart_rules' => $cart_rules,
'delivery_address' => $formatted_delivery_address,
'invoice_address' => $formatted_invoice_address,
'addresses' => array('invoice' => $invoice_address, 'delivery' => $delivery_address),
'tax_excluded_display' => $tax_excluded_display,
'display_product_images' => $display_product_images,
'layout' => $layout,
'tax_tab' => $this->getTaxTabContent(),
'customer' => $customer,
'footer' => $footer,
'ps_price_compute_precision' => _PS_PRICE_COMPUTE_PRECISION_,
'round_type' => $round_type,
'legal_free_text' => $legal_free_text,
'customer_vat_number' => $invoice_address->vat_number, // <= that doesn't works!!
);
and also adding this to the pdf/invoice.addresses-tab.tpl
<table id="addresses-tab" cellspacing="0" cellpadding="0">
<tr>
<td width="50%">{if $delivery_address}<span class="bold">{l s='Delivery Address' d='Shop.Pdf' pdf='true'}</span><br/><br/>
{$delivery_address}<br/>{$customer_vat_number} // <= that
{/if}
</td>
<td width="50%"><span class="bold">{l s='Billing Address' d='Shop.Pdf' pdf='true'}</span><br/><br/>
{$invoice_address}<br/>{$customer_vat_number} // <= that
</td>
</tr>
</table>
But it doesn't works!
Help please!

i want to integrate sms api to my laravel5-4 project but am having error pointing to my controller "array conversion to string"

my controller
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class MessageController extends Controller
{
public function manyMessage(Request $request){
$message = $request->input("message");
$mobile = $request->input("mobile");
$encodeMessage = urlencode($message);
$authKey = 'BHu2TCgKYAymjrc5iX6ge1NyjePaK1vrrz2e0LbKhTbm3qCIuALM73Fonq0F4EaKvc5zKT7T2PglcjH8DDuB2rhiPL7WXPVr7aDu';
$senderId = 'followupvisitatrion';
$route = 4;
$postData = $request->all();
$mobileNumber = implode('',$postData['mobile']);
$arr = str_split($mobileNumber,11);
$mobiles = implode(",",$arr);
$data = array(
'authKey' => $authKey,
'mobiles' => $mobiles,
'message' => $encodeMessage,
'sender' => $senderId,
'route' => $route,
);
$url = "https://api.infobip.com";
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER =>true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $postData,
));
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,0);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,0);
$output = curl_exec($ch);
if(curl_errno($ch)){
echo 'error :'. curl_error($ch);
}
curl_close($ch);
Session::flash('success', 'Message sent Successfully!');
return redirect("/records");
}
}
my view
<form role="form" action="{{url("/sendMessage")}}" method="post">
{{csrf_field()}}
<textarea type="hidden" class="form-control" row="4">Write Text</textarea><br>
<input type="submit" class="pull-left btn btn-primary btn-small" value="Send"/><br /><br />
<input type="checkbox" id="select_all" name="select_all"/> Select All<br/><br />
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
New Converts / First Timer
</div>
<!-- /.panel-heading -->
<div class="panel-body">
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th></th>
<th>Name</th>
<th>Phone Number</th>
<th>Home Address</th>
<th>Email Address</th>
<th>Date</th>
<th>Action</th>
</tr>
</thead>
<tbody>
#if(isset($record))
#foreach($record as $record)
<tr class="odd gradeX">
<td><input type="checkbox" class="checkbox" name="mobile[]" value="{{$record->phone}}"></td>
<td>{{$record->first_name}} - {{$record->last_name}}</td>
<td>{{$record->phone}}</td>
<td>{{$record->home_address}}</td>
<td>{{$record->email}}</td>
<td>{{ Carbon\Carbon::parse($record->created_at)->format('d-m-Y H:i:s') }}</td>
<td><div class="">
Edit
Delete
</div></td>
</tr>
#endforeach
#endif
</tbody>
</table>
</div>
</form>
ERROR
(1/1) ErrorException
Array to string conversion
in MessageController.php (line 37)
at HandleExceptions->handleError(8, 'Array to string conversion', 'C:\\xampp\\htdocs\\blog\\app\\Http\\Controllers\\MessageController.php', 37, array('request' => object(Request), 'message' => null, 'mobile' => array('08028479963'), 'encodeMessage' => '', 'authKey' => 'BHu2TCgKYAymjrc5iX6ge1NyjePaK1vrrz2e0LbKhTbm3qCIuALM73Fonq0F4EaKvc5zKT7T2PglcjH8DDuB2rhiPL7WXPVr7aDu', 'senderId' => 'followupvisitatrion', 'route' => 4, 'postData' => array('_token' => 'p7Cg8f0nQzCjwuuVz83WmQngvp7zeiGnQRQS8FPi', 'dataTables-example_length' => '10', 'mobile' => 'Array'), 'mobileNumber' => '08028479963', 'arr' => array('08028479963'), 'mobiles' => '08028479963', 'data' => array('authKey' => 'BHu2TCgKYAymjrc5iX6ge1NyjePaK1vrrz2e0LbKhTbm3qCIuALM73Fonq0F4EaKvc5zKT7T2PglcjH8DDuB2rhiPL7WXPVr7aDu', 'mobiles' => '08028479963', 'message' => '', 'sender' => 'followupvisitatrion', 'route' => 4), 'url' => 'https://api.infobip.com', 'ch' => resource))
at curl_setopt_array(resource, array('https://api.infobip.com', 1, 1, array('_token' => 'p7Cg8f0nQzCjwuuVz83WmQngvp7zeiGnQRQS8FPi', 'dataTables-example_length' => '10', 'mobile' => 'Array')))
in MessageController.php (line 37)

CODEIGNITER: dynamically get drop down list but first to appear in list is the selected value

i have a table category that consist of (Dessert,Halal,Vegetarian). i was trying to create a CRUD. now i select the Dessert in my drop down list so i want to fetch all the value in my drop down but i want the Dessert to be seen first in dropdown. this is my code:
VIEW:
<?php $product_id = $product['recipe_id']; ?>
<?php echo form_open("dashboard/edit_product/$product_id");?>
<table>
<tr>
<td>Recipe Name: </td>
<td><?php echo form_input($r_name);?>
<div class="cleaner h10"></div>
</td>
</tr>
<tr>
<td>Recipe Category: </td>
<td><select name="r_category">
<option value=""><?php echo $r_category['value'];?></option>
</select>.
<div class="cleaner h10"></div>
</td>
</tr>
<tr>
<td>Recipe Description: </td>
<td><?php echo form_textarea($r_description); ?>
<div class="cleaner h10"></div></td>
</tr>
<tr>
<td>Recipe Cooking Time: </td>
<td><select name="cooking_time">
<option value=""><?php echo $cooking_time['value'];?></option>
</select>.
<div class="cleaner h10"></div>
</td>
</tr>
<tr>
<tr>
<td>Recipe Calories: </td>
<td><?php echo form_input($r_cal);?>
<div class="cleaner h10"></div>
</td>
</tr>
<tr>
<td>Recipe Serving Size: </td>
<td><?php echo form_input($r_serve);?>
<div class="cleaner h10"></div>
</td>
</tr>
<td>Recipe Procedure: </td>
<td><?php echo form_textarea($r_procedure); ?>
<div class="cleaner h10"></div></td>
</tr>
<td> </td>
<td><?php echo form_submit('submit', 'Submit');?>
<input type="button" name="btnBack" id="btnBack" value="Back" onclick="window.location.href='<?php echo base_url() ?>dashboard'" />
</td>
</tr>
</table>
CONTROLLER:
function edit_product($product_id) {
$product = $this->products_model->get_product($product_id);
$this->load->model('products_model');
$this->data['title'] = 'Edit Recipe';
//validate form input
$this->form_validation->set_rules('r_name', 'Recipe name', 'required|xss_clean');
$this->form_validation->set_rules('r_description', 'Recipe description', 'required|xss_clean');
$this->form_validation->set_rules('r_cal', 'Recipe Calories', 'required|xss_clean');
$this->form_validation->set_rules('r_serve', 'Recipe Serving Size', 'required|xss_clean');
$this->form_validation->set_rules('r_procedure', 'Recipe procedure', 'required|xss_clean');
if (isset($_POST) && !empty($_POST))
{
$data = array(
'r_name' => $this->input->post('r_name'),
'r_category' => $this->input->post('r_category'),
'r_description' => $this->input->post('r_description'),
'cooking_time' => $this->input->post('cooking_time'),
'r_cal' => $this->input->post('r_cal'),
'r_serve' => $this->input->post('r_serve'),
'r_procedure' => $this->input->post('r_procedure'),
);
if ($this->form_validation->run() === true)
{
$this->products_model->update_product($product_id, $data);
$this->session->set_flashdata('message', "<p>Recipe updated successfully.</p>");
redirect(base_url().'dashboard/edit_product/'.$product_id);
}
}
$this->data['message'] = (validation_errors() ? validation_errors() : $this->session->flashdata('message'));
$this->data['product'] = $product;
//display the edit product form
$this->data['r_name'] = array(
'name' => 'r_name',
'id' => 'r_name',
'type' => 'text',
'style' => 'width:300px;',
'value' => $this->form_validation->set_value('r_name', $product['r_name']),
);
$this->data['r_image'] = array(
'name' => 'r_image',
'id' => 'r_image',
'type' => 'text',
'style' => 'width:300px;',
'value' => $this->form_validation->set_value('r_image', $product['r_image']),
);
$this->data['r_category'] = array(
'name' => 'r_category',
'id' => 'r_category',
'type' => 'text',
'style' => 'width:300px;',
'value' => $this->form_validation->set_value('r_category', $product['r_category']),
);
$this->data['r_description'] = array(
'name' => 'r_description',
'id' => 'r_description',
'type' => 'text',
'style' => 'width:300px;',
'value' => $this->form_validation->set_value('r_description', $product['r_description']),
);
$this->data['cooking_time'] = array(
'name' => 'cooking_time',
'id' => 'cooking_time',
'type' => 'text',
'style' => 'width:300px;',
'value' => $this->form_validation->set_value('cooking_time', $product['cooking_time']),
);
$this->data['r_cal'] = array(
'name' => 'r_cal',
'id' => 'r_cal',
'type' => 'text',
'style' => 'width:300px;',
'value' => $this->form_validation->set_value('r_cal', $product['r_cal']),
);
$this->data['r_serve'] = array(
'name' => 'r_serve',
'id' => 'r_serve',
'type' => 'text',
'style' => 'width:300px;',
'value' => $this->form_validation->set_value('r_serve', $product['r_serve']),
);
$this->data['r_procedure'] = array(
'name' => 'r_procedure',
'id' => 'r_procedure',
'type' => 'text',
'style' => 'width:300px;',
'value' => $this->form_validation->set_value('r_procedure', $product['r_procedure']),
);
//var_dump($this->data);
$this->load->view('edit_product', $this->data);
}
model:
function get_product($product_id) {
$this->db->select('*');
$this->db->where('recipe_id', $product_id);
$query = $this->db->get('recipe');
return $query->row_array();
}

Image validation in cakephp not working properly

I am trying to add image server side validation in cakephp but they are not working properly could anyone help me...i am new in cakephp...here is my view and model file code:-
I am using custom plugin name "Account"
Account.php
class Account extends AccountAppModel {
public $useTable = 'users';
public $name = "Account";
public $validate = array(
'name' => array(
'rule1' => array(
'rule' => 'notEmpty',
'message' => 'Please enter your name!'
),
'alphaNumeric' => array(
'rule' => 'alphaNumeric',
'message' => 'Name must be alphabetic or number!'
),
'between' => array(
'rule' => array('between', 3, 20),
'on' => 'create',
'message' => 'Name must be between 5to20 character!'
),
'isUnique' => array(
'rule' => 'isUnique',
'on' => 'create',
'message' => 'Name already taken! please choose another-one!'
)
),
'email'=>array(
'notEmpty'=>array(
'rule'=>'notEmpty',
'message'=>'Please enter Mail ID!'
),
'email'=>array(
'rule'=>'email',
'message'=>'Please enter a valid mail id!'
)
),
'region'=>array(
'rule'=>'notEmpty',
'message'=>'Please enter Region!'
),
'city'=>array(
'rule'=>'notEmpty',
'message'=>'Please enter City!'
),
'password'=>array(
'notEmpty'=>array(
'rule'=>'notEmpty',
'message'=>'please enter password'
),
'between'=>array(
'rule'=>array('between', 5,20),
'message'=>'password must be between 5 to 20 character'
)
),
'cpassword'=>array(
'compare' => array(
'rule'=>array('confirmPassword'),
'message' => 'Password do not match please try again!'
)
),
'photo'=>array(
'mimeType'=>array(
'rule'=>array('mimeType',"photo","photo"),
'message'=>'Please enter a valid image!'
),
'fileSize'=>array(
'rule' => array('fileSize', '<=', '1MB'),
'message'=>'Image is too big please try again!'
),
'uploadError'=>array(
'rule'=>'uploadError',
'message'=>'File upload field!'
)
),
'photo_id'=>array(
'mimeType'=>array(
'rule'=>array('mimeType','photo_id','photo_id'),
'message'=>'Please enter a valid image!'
),
'fileSize'=>array(
'rule'=>array('fileSize','<=','1MB'),
'message'=>'Image is too big please try again!'
),
'uploadError'=>array(
'rule'=>'uploadError',
'message'=>'File upload field!'
)
)
);
function confirmPassword()
{
return $this->data['Account']['password']==$this->data['Account']['cpassword'];
}
public function mimeType($field = null,$cfield = null){
//pr($cfield) or die;
if(isset($field[$cfield]["tmp_name"]) && !empty($field[$cfield]["tmp_name"]))
{
$size = #getimagesize($field[$cfield]["tmp_name"]);
//pr($size) or die;
$imgType = array('image/jpeg','image/jpg');
if(in_array($size['mime'],$imgType)){
$return = true;
}
else{
$return = false;
}
return $return;
}
}
}
and here is add.ctp file code:-
<?php echo $this->Form->create('Account',array('type'=>"file")); ?>
<table width='800px' border='0' align='center'>
<tr>
<td>Name :</td>
<td>
<?php
echo $this->Form->input('name',array('label'=>false,'data-rule-required'=>true,'lettersonly'=>true,"required"=>false));
?>
</td>
<td>E-Mail :</td>
<td>
<?php
echo $this->Form->input('email',
array('label'=>false,'required'=>false,'type'=>'text'));
?>
</td>
</tr>
<tr>
<td>Region :</td>
<td>
<?php
echo $this->Form->input('region',
array('type'=>'select',
'empty'=>'Select Region',
'options'=>$strlt,
'label'=>false,
'id'=>'name',
'data-rule-required'=>true,'required'=>false));
?>
</td>
<td>City :</td>
<td>
<?php
echo $this->Form->input('city',
array('type'=>'select',
'empty'=>'Select City',
'options'=>'',
'label'=>false,
'id'=>'slct',
'data-rule-required'=>true,'required'=>false
)
);
?>
</td>
</tr>
<tr>
<td>Password :</td>
<td>
<?php
echo $this->Form->input('password',
array('type'=>'password',
'label'=>false,
'data-rule-required'=>true,
'id'=>'pass_id',
'required'=>false));
?>
</td>
<td>Confirm Password :</td>
<td>
<?php
echo $this->Form->input('cpassword',
array('type'=>'password',
'label'=>false,
'data-rule-required'=>true,
'equalTo'=>'pass_id','required'=>false));
?>
</td>
</tr>
<tr>
<td>Address</td>
<td>
<?php
echo $this->Form->input('address',
array('label'=>false,
'data-rule-required'=>true,'required'=>false));
?>
</td>
<td>Zip-Code :</td>
<td>
<?php
echo $this->Form->input('zip',
array('label'=>false,
'data-rule-required'=>true,'required'=>false));
?>
</td>
</tr>
<tr>
<td>About Me :</td>
<td>
<?php
echo $this->Form->textarea('about_me',
array('label'=>false,
'data-rule-required'=>true,'required'=>false));
?>
</td>
<td>Contact No :</td>
<td>
<?php
echo $this->Form->input('contact_no',
array('label'=>false,
'data-rule-required'=>true,'required'=>false));
?>
</td>
</tr>
<tr>
<td>Upload Photo :</td>
<td>
<?php
echo $this->Form->input('photo',
array('type'=>'file',
'label'=>false,
'data-rule-required'=>true,'required'=>false));
?>
</td>
<td>Photo ID :</td>
<td>
<?php
echo $this->Form->input('photo_id',
array('type'=>'file',
'label'=>false,
'data-rule-required'=>true,'required'=>false));
?>
</td>
</tr>
<tr>
<td>Show Info :</td>
<td>
<?php
echo $this->Form->input('show_info',
array('type'=>'checkbox',
'label'=>false));
?>
</td>
<td>Premium Member :</td>
<td>
<?php
echo $this->Form->input('membership',
array('type'=>'checkbox',
'label'=>false,'required'=>false));
?>
</td>
</tr>
<tr>
<td>Unit / Company :</td>
<td>
<?php
echo $this->Form->input('user_type', array(
'type' => 'select',
'options' => array('unit' => 'Unit', 'company' => 'Company'),
'selected' => 'Unit',
'label'=>false,
'data-rule-required'=>true,'required'=>false
));
?>
</td>
<td>Status :</td>
<td>
<?php
echo $this->Form->input('status',
array('type'=>'select',
'options'=>array('1'=>'Active',
'0'=>'Inactive'),
'label'=>false,
'data-rule-required'=>true,'required'=>false));
?>
</td>
</tr>
<tr><td colspan=2>
<?php echo $this->Form->input('submit',
array('type'=>'submit',
'label'=>false,'class'=>'btn btn-default','id'=>'sb'));
?>
<?php
echo $this->Html->link('Cancel',
array('plugin'=>'account',
'controller'=>'accounts',
'action'=>'index'),
array('class'=>'btn btn-primary',
'div'=>false,
'escape'=>false,
'id'=>'sb'
)
);
?>
<td><tr>
</table>
<?php echo $this->Form->end();?>
Use Rule ,(Replace your image rule with this)
'photo_id'=>array(
'mimeType'=>array(
'rule' => array('mimeType', array('image/gif', 'image/png', 'image/jpg', 'image/jpeg')),
'message'=>'Please enter a valid image!'
),

set image after text box in zend form using zend decorator

I am using zend form and zend decorator to create a form. and I want to set a image after a text box. like this:
I am using zend decorator but it is giving me like this:
I am using this code:
Class CountryController extends Zend_Controller_Action
{
public $textimage = array(
'ViewHelper',
array('FormElements',array('tag'=>'img')),
'FormElements',
array(array('openerror' => 'HtmlTag'),array('tag' => 'td', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND,'width'=>'37%')),
'Errors',
array(array('closeerror' => 'HtmlTag'),array('tag' => 'td', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)),
array(array('elementImg' => 'HtmlTag'), array('tag' => 'img','class'=>'imgpos')),
array('HtmlTag', array('tag' => 'td','align'=>'left')),
array('Label', array('tag' => 'td')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr','valign'=>'top','align'=>'right')),
);
public $elementDecorators = array(
'ViewHelper',
'FormElements',
array(array('openerror' => 'HtmlTag'),array('tag' => 'td', 'openOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)),
'Errors',
array(array('closeerror' => 'HtmlTag'),array('tag' => 'td', 'closeOnly' => true, 'placement' => Zend_Form_Decorator_Abstract::APPEND)),
array('HtmlTag', array('tag' => 'td', 'class' => 'element','align'=>'left','colspan'=>'2')),
array('Label', array('tag' => 'td')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr','valign'=>'top','align'=>'right')),
);
public $buttonDecorators = array(
'ViewHelper',
'Errors',
'FormElements',
array('HtmlTag', array('tag' => 'td','align'=>'left')),
array(array('row' => 'HtmlTag'), array('tag' => 'div')),
);
public $addButton = array(
'ViewHelper',
'Errors',
'FormElements',
array('HtmlTag', array('tag' => 'td','align'=>'right')),
array(array('row' => 'HtmlTag'), array('tag' => 'div')),
);
//======================add action for country============================
public function addAction()
{
$request = $this->getRequest();
$form = new Zend_Form;
$form->setAction('add')
->setMethod('POST')
->setAttrib('Name','addfrm')
->setAttrib('Id','addfrm');
$form->addElements(array(
new Zend_Form_Element_Text('cou_name',array(
'decorators' => $this->textimage,
'required' => true,
'label' => 'Country Name :',
'class'=>'textpos',
'validator'=>'Alpha',
)),
new Zend_Form_Element_Textarea('description',array(
'decorators' => $this->textimage,
'required' => true,
'label' => 'Country Description :',
'rows'=>10,
'cols'=>40,
'validator'=>'NotEmpty',
'class'=>'textpos',
)),
new Zend_Form_Element_Checkbox('block',array(
'decorators' => $this->elementDecorators,
'Label'=>'Block :',
'Value'=>'1',
)),
new Zend_Form_Element_Radio('block_r',array(
'decorators' => $this->elementDecorators,
'Label'=>'Block :',
'multiOptions'=>array(0=>'Yes',1=>'No'),
'Separator'=>'',
)),
new Zend_Form_Element_Submit('add',array(
'decorators' => $this->addButton,
'Label'=>'Add',
)),
new Zend_Form_Element_Button('back',array(
'decorators' => $this->buttonDecorators,
'Label'=>'Back',
'onclick'=>'window.location="list"',
)),
));
$form->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'table','align'=>'center','class'=>'tbcss','width'=>'84%')),
'Form',
));
$this->view->assign('form',$form);
}
}
I am using IE6.
the generated code is this:
<div class="container">
<form enctype="application/x-www-form-urlencoded" action="add"
method="post" Name="addfrm" Id="addfrm" name="">
<table align="center" class="tbcss" width="84%">
<tr valign="top" align="right">
<td id="cou_name-label"><label for="cou_name" class="required">Country
Name :</label></td>
> <td align="left"><img class="imgpos"> <input type="text"
> name="cou_name" id="cou_name" value="" class="textpos"
> validator="Alpha" />
> <td width="37%"></td>
> </img></td>
</tr>
<tr valign="top" align="right">
<td id="description-label"><label for="description"
class="required">Country Description :</label></td>
<td align="left"><img class="imgpos"> <textarea
name="description" id="description" rows="10" cols="40"
validator="NotEmpty" class="textpos"></textarea>
<td width="37%"></td>
</img></td>
</tr>
<tr valign="top" align="right">
<td id="block-label"><label for="block" class="optional">Block
:</label></td>
<td class="element" align="left" colspan="2"><input type="hidden"
name="block" value="0" /><input type="checkbox" name="block"
id="block" value="1" checked="checked" />
<td></td>
</td>
</tr>
<tr valign="top" align="right">
<td id="block_r-label"><label class="optional">Block :</label></td>
<td class="element" align="left" colspan="2"><label
for="block_r-0"><input type="radio" name="block_r"
id="block_r-0" value="0" />Yes</label><label for="block_r-1"><input
type="radio" name="block_r" id="block_r-1" value="1" />No</label>
<td></td>
</td>
</tr>
<div>
<td align="right"><input type="submit" name="add" id="add"
value="Add" /></td>
</div>
<div>
<td align="left">
<button name="back" id="back" type="button"
onclick=
window.location = "list";
Back</button>
</td>
</div>
</table>
</form>
</div>
Can anyone help me plz.
In your css just add
.imgpos {
float: right;
}
Also you can try float .textpos to left

Categories