| @@ 200-211 (lines=12) @@ | ||
| 197 | * @param string $name Field name |
|
| 198 | * @param string $label Field label |
|
| 199 | */ |
|
| 200 | protected function __construct( $name, $label ) { |
|
| 201 | $this->set_name( $name ); |
|
| 202 | $this->set_label( $label ); |
|
| 203 | $this->set_base_name( $name ); |
|
| 204 | ||
| 205 | // Pick random ID |
|
| 206 | $random_string = md5( mt_rand() . $this->get_name() . $this->get_label() ); |
|
| 207 | $random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough |
|
| 208 | $this->id = 'carbon-' . $random_string; |
|
| 209 | ||
| 210 | $this->init(); |
|
| 211 | } |
|
| 212 | ||
| 213 | /** |
|
| 214 | * Boot the field once the container is attached. |
|
| @@ 59-68 (lines=10) @@ | ||
| 56 | * @param string $label |
|
| 57 | * @param array $fields |
|
| 58 | */ |
|
| 59 | public function __construct( $name, $label, $fields ) { |
|
| 60 | $this->set_name( $name ); |
|
| 61 | $this->set_label( $label ); |
|
| 62 | $this->add_fields( $fields ); |
|
| 63 | ||
| 64 | // Pick random ID |
|
| 65 | $random_string = md5( mt_rand() . $this->get_name() . $this->get_label() ); |
|
| 66 | $random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough |
|
| 67 | $this->group_id = 'carbon-group-' . $random_string; |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Add a group of fields. |
|