本文整理汇总了PHP中Contacts::attributeLabels方法的典型用法代码示例。如果您正苦于以下问题:PHP Contacts::attributeLabels方法的具体用法?PHP Contacts::attributeLabels怎么用?PHP Contacts::attributeLabels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Contacts
的用法示例。
在下文中一共展示了Contacts::attributeLabels方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSearch
public function actionSearch()
{
$model = new Contacts();
$attributeLabels = $model->attributeLabels();
if (isset($_POST['Contacts'])) {
$model->attributes = $_POST['Contacts'];
$firstName = true;
$lastName = true;
if ($model->firstName == $attributeLabels['firstName']) {
$firstName = false;
}
if ($model->lastName == $attributeLabels['lastName']) {
$lastName = false;
}
if ($firstName && $lastName) {
$dataProvider = new CActiveDataProvider('Contacts', array('criteria' => array('order' => 'lastName ASC', 'condition' => "firstName='{$model->firstName}' AND lastName='{$model->lastName}'")));
} else {
if ($firstName && !$lastName) {
$dataProvider = new CActiveDataProvider('Contacts', array('criteria' => array('order' => 'firstName ASC', 'condition' => "firstName='{$model->firstName}'")));
} else {
if (!$firstName && $lastName) {
$dataProvider = new CActiveDataProvider('Contacts', array('criteria' => array('order' => 'lastName ASC', 'condition' => "lastName='{$model->lastName}'")));
} else {
$this->redirect($this->createUrl('site/home'));
}
}
}
$this->render('viewAll', array('dataProvider' => $dataProvider));
} else {
$this->render('search', array('model' => $model));
}
}
示例2: actionSearch
public function actionSearch()
{
$model = new Contacts();
$attributeLabels = $model->attributeLabels();
if (isset($_POST['Contacts'])) {
$model->attributes = $_POST['Contacts'];
$firstName = true;
$lastName = true;
if ($model->firstName === '') {
$firstName = false;
}
if ($model->lastName === '') {
$lastName = false;
}
if ($firstName && $lastName) {
$dataProvider = new CActiveDataProvider('Contacts', array('criteria' => array('order' => 'lastName ASC', 'condition' => "firstName='{$model->firstName}' AND lastName='{$model->lastName}'")));
} else {
if ($firstName && !$lastName) {
$dataProvider = new CActiveDataProvider('Contacts', array('criteria' => array('order' => 'firstName ASC', 'condition' => "firstName='{$model->firstName}'")));
} else {
if (!$firstName && $lastName) {
$dataProvider = new CActiveDataProvider('Contacts', array('criteria' => array('order' => 'lastName ASC', 'condition' => "lastName='{$model->lastName}'")));
} else {
// If both fields are blank
//$this->redirect($this->createUrl('/mobile/site/home'));
$model->addError('lastName', 'Please fill out at least one search field.');
$this->render('search', array('model' => $model));
}
}
}
$this->render('viewAll', array('dataProvider' => $dataProvider));
} else {
$this->render('search', array('model' => $model));
}
}
示例3: array
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
********************************************************************************/
Yii::app()->clientScript->registerScriptFile(Yii::app()->getBaseUrl() . '/js/x2forms.js');
$prof = Profile::model()->findByPk(Yii::app()->user->getId());
// if($prof->widgets=='1'){
// Yii::app()->clientScript->registerScript('updateChat', "
// ",CClientScript::POS_HEAD);
// }
$menuItems = array(array('label' => Yii::t('app', 'Main Menu'), 'url' => array('site/home/')));
$this->widget('MenuList', array('id' => 'main-menu', 'items' => $menuItems));
$model = new Contacts();
$attributeLabels = $model->attributeLabels();
$form = $this->beginWidget('CActiveForm', array('id' => 'quick-contact-form', 'action' => '', 'enableAjaxValidation' => false, 'method' => 'POST'));
$model->firstName = $attributeLabels['firstName'];
$model->lastName = $attributeLabels['lastName'];
$model->phone = $attributeLabels['phone'];
$model->email = $attributeLabels['email'];
?>
<div class="form thin">
<div class="row">
<?php
echo $form->textField($model, 'firstName', array('maxlength' => 40, 'tabindex' => 100, 'onfocus' => 'toggleText(this);', 'onblur' => 'toggleText(this);', 'style' => 'color:#aaa;width:275px;'));
?>
<?php
echo $form->error($model, 'firstName');
?>
示例4: actionUpdateList
public function actionUpdateList($id)
{
$list = X2List::model()->findByPk($id);
if (!isset($list)) {
throw new CHttpException(400, Yii::t('app', 'This list cannot be found.'));
}
if (!$this->editPermissions($list)) {
throw new CHttpException(403, Yii::t('app', 'You do not have permission to modify this list.'));
}
$contactModel = new Contacts();
$comparisonList = array('=' => '=', '>' => '>', '<' => '<', '<>' => '<>', 'contains' => Yii::t('contacts', 'contains'), 'empty' => Yii::t('empty', 'empty'), 'notEmpty' => Yii::t('contacts', 'not empty'), 'list' => Yii::t('contacts', 'in list'));
if ($list->type == 'dynamic') {
$criteriaModels = X2ListCriterion::model()->findAllByAttributes(array('listId' => $list->id), new CDbCriteria(array('order' => 'id ASC')));
}
if (isset($_POST['X2List'], $_POST['X2List']['attribute'], $_POST['X2List']['comparison'], $_POST['X2List']['value'])) {
$attributes =& $_POST['X2List']['attribute'];
$comparisons =& $_POST['X2List']['comparison'];
$values =& $_POST['X2List']['value'];
if (count($attributes) > 0 && count($attributes) == count($comparisons) && count($comparisons) == count($values)) {
$list->attributes = $_POST['X2List'];
$list->modelName = 'Contacts';
$list->lastUpdated = time();
if ($list->save()) {
X2ListCriterion::model()->deleteAllByAttributes(array('listId' => $list->id));
// delete old criteria
for ($i = 0; $i < count($attributes); $i++) {
// create new criteria
if ((array_key_exists($attributes[$i], $contactModel->attributeLabels()) || $attributes[$i] == 'tags') && array_key_exists($comparisons[$i], $comparisonList)) {
//&& $values[$i] != ''
$criterion = new X2ListCriterion();
$criterion->listId = $list->id;
$criterion->type = 'attribute';
$criterion->attribute = $attributes[$i];
$criterion->comparison = $comparisons[$i];
$criterion->value = $values[$i];
$criterion->save();
}
}
$this->redirect(array('/contacts/list/' . $list->id));
}
}
}
if (empty($criteriaModels)) {
$default = new X2ListCriterion();
$default->value = '';
$default->attribute = '';
$default->comparison = 'contains';
$criteriaModels[] = $default;
}
$this->render('updateList', array('model' => $list, 'criteriaModels' => $criteriaModels, 'users' => User::getNames(), 'comparisonList' => $comparisonList, 'listTypes' => array('dynamic' => Yii::t('contacts', 'Dynamic'), 'static' => Yii::t('contacts', 'Static')), 'itemModel' => $contactModel));
}