Skip to content

Commit

Permalink
Merge pull request #1131 from willkoua/1107_bug_edit_profile
Browse files Browse the repository at this point in the history
modification de la table user
  • Loading branch information
willkoua committed May 12, 2016
2 parents 16be7fb + 9dbb44d commit 993a154
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
39 changes: 39 additions & 0 deletions config/Migrations/20160510151928_modify_users_to_integer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

use Phinx\Migration\AbstractMigration;

class ModifyUsersToInteger extends AbstractMigration
{
/**
* Change Method.
*
* Write your reversible migrations using this method.
*
* More information on writing migrations is available here:
* http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
*
* The following commands can be used in this method and Phinx will
* automatically reverse them when rolling back:
*
* createTable
* renameTable
* addColumn
* renameColumn
* addIndex
* addForeignKey
*
* Remember to call "create()" or "update()" and NOT "save()" when working
* with the Table class.
*/
public function change()
{
$this->execute('UPDATE users SET gender = 2 WHERE gender IS NULL ');

$table = $this->table('users');
$table->changeColumn('gender', 'integer', [
'default' => 2,
'limit' => 2,
'null' => false
]);
}
}
2 changes: 1 addition & 1 deletion src/Controller/UsersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,6 @@ public function edit($id = null)

if ($this->request->is(['patch', 'post', 'put'])) {
$user = $this->Users->patchEntity($user, $this->request->data);

if ($this->Users->save($user)) {
//Update the language
$this->request->session()->write('lang', $user->getLanguage());
Expand All @@ -515,6 +514,7 @@ public function edit($id = null)
);
}
}

$universities = $this->Users->Universities->find('list', ['limit' => 200]);
$this->set(compact('user', 'universities', 'you', 'typeOptions', 'selectedTypeMissions'));
$this->set('_serialize', ['user']);
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Users/edit.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<?= $this->Form->label('gender', __('Gender'), ['class' => 'control-label']); ?>
<select class="form-control" name="gender">
<option
value="null" <?= (is_null($user->getGender()) ? "selected" : ""); ?>><?= __('Not specified'); ?></option>
value="2" <?= (is_null($user->getGender()) ? "selected" : ""); ?>><?= __('Not specified'); ?></option>
<option
value="0" <?= (!$user->getGender() && !is_null($user->getGender()) ? "selected" : ""); ?>><?= __('Female'); ?></option>
<option value="1" <?= ($user->getGender() ? "selected" : ""); ?>><?= __('Male'); ?></option>
Expand Down

0 comments on commit 993a154

Please sign in to comment.