| @@ 228-239 (lines=12) @@ | ||
| 225 | * @param string $name Field name |
|
| 226 | * @param string $label Field label |
|
| 227 | */ |
|
| 228 | protected function __construct( $name, $label ) { |
|
| 229 | $this->set_base_name( $name ); |
|
| 230 | $this->set_name( $name ); |
|
| 231 | $this->set_label( $label ); |
|
| 232 | ||
| 233 | // Pick random ID |
|
| 234 | $random_string = md5( mt_rand() . $this->get_name() . $this->get_label() ); |
|
| 235 | $random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough |
|
| 236 | $this->id = 'carbon-' . $random_string; |
|
| 237 | ||
| 238 | $this->init(); |
|
| 239 | } |
|
| 240 | ||
| 241 | /** |
|
| 242 | * Boot the field once the container is attached. |
|
| @@ 62-71 (lines=10) @@ | ||
| 59 | * @param string $label |
|
| 60 | * @param array $fields |
|
| 61 | */ |
|
| 62 | public function __construct( $name, $label, $fields ) { |
|
| 63 | $this->set_name( $name ); |
|
| 64 | $this->set_label( $label ); |
|
| 65 | $this->add_fields( $fields ); |
|
| 66 | ||
| 67 | // Pick random ID |
|
| 68 | $random_string = md5( mt_rand() . $this->get_name() . $this->get_label() ); |
|
| 69 | $random_string = substr( $random_string, 0, 5 ); // 5 chars should be enough |
|
| 70 | $this->group_id = 'carbon-group-' . $random_string; |
|
| 71 | } |
|
| 72 | ||
| 73 | /** |
|
| 74 | * Add a group of fields. |
|