Skip to content

Commit

Permalink
Fixed a children attribute bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
inc2734 committed Jan 20, 2015
1 parent 0e92b47 commit 2a23ae2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
15 changes: 8 additions & 7 deletions classes/form-fields/class.checkbox.php
Expand Up @@ -2,11 +2,11 @@
/**
* Name : MW WP Form Field Checkbox
* Description: チェックボックスを出力
* Version : 1.5.0
* Version : 1.5.1
* Author : Takashi Kitajima
* Author URI : http://2inc.org
* Created : December 14, 2012
* Modified : January 2, 2015
* Modified : January 20, 2015
* License : GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Expand Down Expand Up @@ -74,11 +74,12 @@ protected function input_page() {
* @return string HTML
*/
protected function confirm_page() {
$children = $this->get_children( $this->atts['children'] );
$value = $this->Form->get_checked_value( $this->atts['name'], $children );
$_ret = esc_html( $value );
$_ret .= $this->Form->hidden( $this->atts['name'] . '[data]', $value );
$_ret .= $this->Form->separator( $this->atts['name'] );
$children = $this->get_children( $this->atts['children'] );
$value = $this->Form->get_checked_value( $this->atts['name'], $children );
$posted_value = $this->Form->get_raw( $this->atts['name'] );
$_ret = esc_html( $value );
$_ret .= $this->Form->hidden( $this->atts['name'] . '[data]', $posted_value );
$_ret .= $this->Form->separator( $this->atts['name'] );
return $_ret;
}

Expand Down
13 changes: 7 additions & 6 deletions classes/form-fields/class.radio.php
Expand Up @@ -2,11 +2,11 @@
/**
* Name : MW WP Form Field Radio
* Description: ラジオボタンを出力
* Version : 1.5.0
* Version : 1.5.1
* Author : Takashi Kitajima
* Author URI : http://2inc.org
* Created : December 14, 2012
* Modified : January 2, 2015
* Modified : January 20, 2015
* License : GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Expand Down Expand Up @@ -71,10 +71,11 @@ protected function input_page() {
* @return string HTML
*/
protected function confirm_page() {
$children = $this->get_children( $this->atts['children'] );
$value = $this->Form->get_radio_value( $this->atts['name'], $children );
$_ret = esc_html( $value );
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
$children = $this->get_children( $this->atts['children'] );
$value = $this->Form->get_radio_value( $this->atts['name'], $children );
$posted_value = $this->Form->get_raw( $this->atts['name'] );
$_ret = esc_html( $value );
$_ret .= $this->Form->hidden( $this->atts['name'], $posted_value );
return $_ret;
}

Expand Down
13 changes: 7 additions & 6 deletions classes/form-fields/class.select.php
Expand Up @@ -2,11 +2,11 @@
/**
* Name : MW WP Form Field Select
* Description: セレクトボックスを出力
* Version : 1.5.0
* Version : 1.5.1
* Author : Takashi Kitajima
* Author URI : http://2inc.org
* Created : December 14, 2012
* Modified : January 2, 2015
* Modified : January 20, 2015
* License : GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Expand Down Expand Up @@ -69,10 +69,11 @@ protected function input_page() {
* @return string HTML
*/
protected function confirm_page() {
$children = $this->get_children( $this->atts['children'] );
$value = $this->Form->get_selected_value( $this->atts['name'], $children );
$_ret = esc_html( $value );
$_ret .= $this->Form->hidden( $this->atts['name'], $value );
$children = $this->get_children( $this->atts['children'] );
$value = $this->Form->get_selected_value( $this->atts['name'], $children );
$posted_value = $this->Form->get_raw( $this->atts['name'] );
$_ret = esc_html( $value );
$_ret .= $this->Form->hidden( $this->atts['name'], $posted_value );
return $_ret;
}

Expand Down
14 changes: 7 additions & 7 deletions classes/models/class.data.php
Expand Up @@ -2,11 +2,11 @@
/**
* Name : MW WP Form Data
* Description: MW WP Form のデータ操作用
* Version : 1.3.1
* Version : 1.3.2
* Author : Takashi Kitajima
* Author URI : http://2inc.org
* Created : October 10, 2013
* Modified : January 14, 2015
* Modified : January 20, 2015
* License : GPLv2
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Expand Down Expand Up @@ -331,19 +331,19 @@ public function getSeparatorValue( $key ) {
*/
public function get_separated_value( $key, array $children = array() ) {
$separator = $this->get_separator_value( $key );
$value = $this->get_raw( $key );
$value = $this->get_raw( $key );
if ( is_array( $value ) && isset( $value['data'] ) && is_array( $value['data'] ) && !empty( $separator ) ) {
if ( $children ) {
$rightData = array();
foreach ( $value['data'] as $child ) {
if ( isset( $children[$child] ) && !in_array( $children[$child], $rightData ) ) {
$rightData[] = $children[$child];
foreach ( $value['data'] as $name => $child ) {
if ( isset( $children[$name] ) && !in_array( $children[$name], $rightData ) ) {
$rightData[] = $children[$name];
}
}
return implode( $separator, $rightData );
} else {
// すべて空のからのときはimplodeしないように(---がいってしまうため)
foreach ( $value['data'] as $child ) {
foreach ( $value['data'] as $name => $child ) {
if ( $child !== '' && $child !== null ) {
return implode( $separator, $value['data'] );
}
Expand Down

0 comments on commit 2a23ae2

Please sign in to comment.