zend-framework

One error message instead of few for Zend validator

☆樱花仙子☆ 提交于 2019-12-12 08:18:10
问题 I have the next element: $email = new Zend_Form_Element_Text('email'); $email->setAttribs(array('class' => 'input-text', 'id' => 'email')) ->setLabel($this->view->translate('Email')) ->setValue(null) ->setRequired(true) ->addValidator(new Zend_Validate_EmailAddress()) ->setDecorators($emailMessageDecorators); If there are more than one mistake in the email address, some errors are displaying. Like this: 'fff.fgdf' is no valid hostname for email address 'as@fff.fgdf' 'fff.fgdf' appears to be a

PHP implode array to generate mysql IN criteria

ε祈祈猫儿з 提交于 2019-12-12 08:14:40
问题 I have a function like the following: public function foo ($cities = array('anaheim', 'baker', 'colfax') ) { $db = global instance of Zend_Db_Adapter_Pdo_Mysql... $query = 'SELECT name FROM user WHERE city IN ('.implode(',',$cities).')'; $result = $db->fetchAll( $query ); } This works out fine until someone passes $cities as an empty array. To prevent this error I have been logic-breaking the query like so: $query = 'SELECT name FROM user'; if (!empty($cities)) { $query .= ' WHERE city IN ('

How to validate a checkbox in ZF2

对着背影说爱祢 提交于 2019-12-12 08:12:29
问题 I've read numerous workarounds for Zend Framework's lack of default checkbox validation. I have recently started using ZF2 and the documentation is a bit lacking out there. Can someone please demonstrate how I can validate a checkbox to ensure it was ticked, using the Zend Form and Validation mechanism? I'm using the array configuration for my Forms (using the default set-up found in the example app on the ZF website). 回答1: Try this Form element : $this->add(array( 'type' => 'Zend\Form

How do you Unit Test a Zend_Form that includes the CSRF form element?

余生长醉 提交于 2019-12-12 08:09:34
问题 I'm using the CSRF hidden hash element with Zend_Form and trying to Unit Test the login but don't know how to write a Unit Test to include that element. Looked in the docs and read as many tutorials as I could find. I even delicioused them all, but no one mentions this. 回答1: The correct hash is stored in the session, and the Hash form element has a Zend_Session_Namespace instance which contains the namespace for the hash. To unit test the element, you would replace the Zend_Session_Namespace

zend form for multicheckbox remove input from labels

廉价感情. 提交于 2019-12-12 07:22:51
问题 I am using zend_form (part of Zend Framwork) to create a form and found when I add a set of checkboxes using Zend_Form's multicheckbox element (Zend_Form_Element_MultiCheckbox) the code that is outputted like so: <label for="subjects-maths"> <input type="checkbox" value="maths" id="subjects-maths" name="subjects[]"> Maths </label> <label for="subjects-english"> <input type="checkbox" value="maths" id="subjects-english" name="subjects[]"> English </label> I.e. the input is inside the label.

How could read application.ini on controller using zend framework

女生的网名这么多〃 提交于 2019-12-12 07:22:46
问题 I have these lines in my application.ini how can I read user in my contrroler resources.doctrine.dbal.connections.default.parameters.driver = "pdo_mysql" resources.doctrine.dbal.connections.default.parameters.dbname = "zc" resources.doctrine.dbal.connections.default.parameters.host = "localhost" resources.doctrine.dbal.connections.default.parameters.port = 3306 resources.doctrine.dbal.connections.default.parameters.user = "root" resources.doctrine.dbal.connections.default.parameters.password

zend_pdf document issue in windows 7

青春壹個敷衍的年華 提交于 2019-12-12 06:27:49
问题 I am using zend_pdf to generate pdf in magento 1.7 and I have tried something like public function getpdf() { $pdf = new Zend_Pdf(); $font = Zend_Pdf_Font::fontWithName(Zend_Pdf_Font::FONT_HELVETICA); $page = new Zend_Pdf_Page(Zend_Pdf_Page::SIZE_A4); $page->setFont($font, 24) ->drawText('Hello World', 72, 720); $pdf->pages[] = $page; $pdfString = $pdf->render(); header("Content-Disposition: attachment; filename=helloworld.pdf"); header("Content-type: application/x-pdf"); echo $pdfString; }

trying to upload a file using ajax file uploaded but in corrupted php ajax jquery

孤者浪人 提交于 2019-12-12 06:18:38
问题 I am trying to upload a file using PHP ajax jquery file is uploading but in corrupted format how can i make it correct. in my controller i am using $product_image = $request->getParam("product_image"); defined('PUBLIC_PATH') || define('PUBLIC_PATH', realpath(dirname(dirname(dirname(dirname(dirname(__FILE__))))))); $filename = time() . rand(10000, 99999) . ".jpg"; file_put_contents(PUBLIC_PATH . "/public_html/product_images/" . $filename, base64_decode($product_image)); $products->__set(

Load Zend Framework Component in Existing Project

自闭症网瘾萝莉.ら 提交于 2019-12-12 06:02:21
问题 I am new to PHP and very new to Zend Framework, so please give me a detailed answer. I have Zend Server (including Zend Framework), Apache, MySql installed on the machine. I have a project created in Eclipse PDT (not with Zend Framework) and I've decided I want to use Zend_Db in my Data Acces Layer. I read many answers here and on other forums, I saw that I should use Zend_Loader but I am not really sure how to begin. I also saw that I need some php extension appropriate to the type of my

How do I pass variables to another action from a search form?

自闭症网瘾萝莉.ら 提交于 2019-12-12 05:59:35
问题 I have two search pages. One is a condensed search form the other is an advanced search. I would like the user to enter their search at on the condensed page and be redirected to the results page which contains the advanced search fields. The two issues I currently have are: How do I redirect? What is the best practice for when a field is left blank? Currently, I keep looking back to the index to get the first two search fields Condensed Search public function indexAction() { $dbAdapter =