php/widgets/TextInputWidget.php
public function setRequired( $state ) {
		$this->required = (bool)$state;
		if ( $this->required ) {
			$this->input->setAttributes( [ 'required' => 'required', 'aria-required' => 'true' ] );
			if ( $this->getIndicator() === null ) {
				$this->setIndicator( 'required' );
			}
		} else {
			$this->input->removeAttributes( [ 'required', 'aria-required' ] );
			if ( $this->getIndicator() === 'required' ) {
				$this->setIndicator( null );
			}
		}
		return $this;
	}
public function setRequired( $state ) {
		$this->required = (bool)$state;
		if ( $this->required ) {
			$this->input->setAttributes( [ 'required' => 'required', 'aria-required' => 'true' ] );
			if ( $this->getIndicator() === null ) {
				$this->setIndicator( 'required' );
			}
		} else {
			$this->input->removeAttributes( [ 'required', 'aria-required' ] );
			if ( $this->getIndicator() === 'required' ) {
				$this->setIndicator( null );
			}
		}
		return $this;
	}
public function setRequired ( $ state ) { $ this -> required = ( bool ) $ state ; if ( $ this -> required ) { $ this -> input -> setAttributes ( [ 'required' => 'required' , 'aria-required' => 'true' ] ) ; if ( $ this -> getIndicator ( ) === null ) { $ this -> setIndicator ( 'required' ) ; } } else { $ this -> input -> removeAttributes ( [ 'required' , 'aria-required' ] ) ; if ( $ this -> getIndicator ( ) === 'required' ) { $ this -> setIndicator ( null ) ; } } return $ this ; }
Set the required state of the widget.

@param bool $state Make input required
@return $this
Set the required state of the widget .