/** * * @return void */ public function contact() { $this->loadModel('content'); Loader::library('Form'); $data = array(); if (Input::post()) { Form::rule('name', 'trim|required|alpha|maxLength:100'); Form::rule('email', 'trim|required|validEmail|maxLength:100'); Form::rule('message', 'trim|required|maxLength:5000'); Form::rule('captcha', 'trim|required|numeric|verifyCaptcha'); if (Form::run() === TRUE) { $sendData = array('name' => Input::post('name'), 'email' => Input::post('email'), 'message' => Input::post('message')); $data = $this->mContent->sendMessage($sendData); } else { $data = array('success' => FALSE, 'result' => Form::errors()); } } $data['sidebarLayout'] = View::render('content/vSidebar', array('page' => 'contact'), TRUE); Layout::title('Contact'); Layout::desc('Contact us.'); Layout::view('content/vContact', $data); }
</div> </div> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><?php echo __('Profile picture'); ?> </h3> </div> <div class="panel-body"> <form class="form-horizontal" enctype="multipart/form-data" method="post" action="<?php echo Route::url('oc-panel', array('controller' => 'profile', 'action' => 'image')); ?> "> <?php echo Form::errors(); ?> <div class="form-group"> <div class="col-md-offset-4 col-md-8"> <img src="<?php echo $user->get_profile_image(); ?> " class="img-rounded ticket_image" alt="<?php echo __('Profile Picture'); ?> " width="120" height="120"> </div> </div> <div class="form-group"> <?php echo FORM::label('profile_img', __('Profile picture'), array('class' => 'col-md-4 control-label', 'for' => 'profile_img'));
echo "redirect_to('thank-you.php')\n"; exit(); } ?> <html> <head> <title>Testing form validation and building</title> </head> <body> <? if ( !$FORM->is_valid() ): ?> <ul id="errors"> <? foreach ( $FORM->errors() as $error ): ?> <li><?= $error ?></li> <? endforeach; ?> </ul> <? endif; ?> <?= $FORM->errors_as_html() ?> <form action="#" method="POST"> <label class="<?= $FORM['name']['valid'] ?> <?= $FORM['name']['required'] ?>"> <?= $FORM['name']['label'] ?>: <input type="text" id="name" name="name" value="<?= $FORM['name'] ?>" /> </label> <label class="<?= $FORM['email_address']['valid'] ?> <?= $FORM['email_address']['required'] ?>"> <?= $FORM['email_address']['label'] ?>: <input type="text" id="email_address" name="email_address" value="<?= $FORM['email_address'] ?>" /> </label>
public function testRepopulate() { Form::$errors = array(); Form::setValues(array('test' => 'something')); $actual = Form::open()->text('test')->close(); $expected = '<form action="" method="post" class="" id="" ><input type="text" name="test" id="test" value="something" class="text" /></form>'; $this->assertEquals(trim_html($expected), trim_html($actual)); // Make sure values override Form::setValues(array('test' => 'something')); $actual = Form::open()->text('test', 'else')->close(); $expected = '<form action="" method="post" class="" id="" ><input type="text" name="test" id="test" value="something" class="text" /></form>'; $this->assertEquals(trim_html($expected), trim_html($actual)); // Make sure values fall through if set directly in the form tag Form::setValues(array('test' => 'something')); $actual = Form::open()->text('test2', 'else')->close(); $expected = '<form action="" method="post" class="" id="" ><input type="text" name="test2" id="test2" value="else" class="text" /></form>'; $this->assertEquals(trim_html($expected), trim_html($actual)); }